summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:03:48 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2008-12-17 18:03:48 -0800
commit4e468ed2eb86a2406e14f1eca82072ee501d05fd (patch)
tree4e05b3c66eef86531e464521a3bf96a1864d4bf5
parenta27d2baa0c1a2ec70f47ea9199b1dd6762c8a349 (diff)
downloadbionic-4e468ed2eb86a2406e14f1eca82072ee501d05fd.zip
bionic-4e468ed2eb86a2406e14f1eca82072ee501d05fd.tar.gz
bionic-4e468ed2eb86a2406e14f1eca82072ee501d05fd.tar.bz2
Code drop from //branches/cupcake/...@124589
-rw-r--r--libc/Android.mk174
-rw-r--r--libc/SYSCALLS.TXT40
-rw-r--r--libc/arch-arm/bionic/memcmp.S19
-rw-r--r--libc/arch-arm/bionic/memcmp16.S19
-rw-r--r--libc/arch-arm/bionic/memcpy.S21
-rw-r--r--libc/arch-arm/bionic/strlen.c3
l---------libc/arch-arm/include/asm1
-rw-r--r--libc/arch-arm/include/machine/_types.h6
-rw-r--r--libc/arch-arm/include/machine/cpu-features.h164
-rw-r--r--libc/arch-arm/syscalls.mk15
-rw-r--r--libc/arch-arm/syscalls/__fork.S (renamed from libc/arch-arm/syscalls/fork.S)6
-rw-r--r--libc/arch-arm/syscalls/__pread64.S21
-rw-r--r--libc/arch-arm/syscalls/__pwrite64.S21
-rw-r--r--libc/arch-arm/syscalls/__timer_create.S (renamed from libc/arch-arm/syscalls/timer_create.S)6
-rw-r--r--libc/arch-arm/syscalls/__timer_delete.S (renamed from libc/arch-arm/syscalls/timer_delete.S)6
-rw-r--r--libc/arch-arm/syscalls/__timer_getoverrun.S (renamed from libc/arch-arm/syscalls/timer_getoverrun.S)6
-rw-r--r--libc/arch-arm/syscalls/__timer_gettime.S (renamed from libc/arch-arm/syscalls/timer_gettime.S)6
-rw-r--r--libc/arch-arm/syscalls/__timer_settime.S (renamed from libc/arch-arm/syscalls/timer_settime.S)6
-rw-r--r--libc/arch-arm/syscalls/getitimer.S19
-rwxr-xr-xlibc/arch-x86/bionic/__get_tls.c4
-rwxr-xr-xlibc/arch-x86/bionic/__set_tls.c14
-rw-r--r--libc/arch-x86/bionic/_exit_with_stack_teardown.S34
-rw-r--r--libc/arch-x86/bionic/_setjmp.S71
-rw-r--r--libc/arch-x86/bionic/atomics_x86.S140
-rw-r--r--libc/arch-x86/bionic/clone.S50
-rw-r--r--libc/arch-x86/bionic/crtbegin_dynamic.S96
-rw-r--r--libc/arch-x86/bionic/crtbegin_so.S29
-rw-r--r--libc/arch-x86/bionic/crtbegin_static.S95
-rw-r--r--libc/arch-x86/bionic/crtend.S13
-rw-r--r--libc/arch-x86/bionic/crtend_so.S47
-rw-r--r--libc/arch-x86/bionic/dl_iterate_phdr_static.c74
-rw-r--r--libc/arch-x86/bionic/setjmp.S93
-rw-r--r--libc/arch-x86/bionic/vfork.S30
-rw-r--r--libc/arch-x86/include/machine/asm.h12
-rw-r--r--libc/arch-x86/include/machine/kernel.h41
-rw-r--r--libc/arch-x86/syscalls.mk171
-rw-r--r--libc/arch-x86/syscalls/__fork.S (renamed from libc/arch-x86/syscalls/fork.S)6
-rw-r--r--libc/arch-x86/syscalls/__pread64.S35
-rw-r--r--libc/arch-x86/syscalls/__pwrite64.S35
-rw-r--r--libc/arch-x86/syscalls/__timer_create.S (renamed from libc/arch-x86/syscalls/timer_create.S)6
-rw-r--r--libc/arch-x86/syscalls/__timer_delete.S (renamed from libc/arch-x86/syscalls/timer_delete.S)6
-rw-r--r--libc/arch-x86/syscalls/__timer_getoverrun.S (renamed from libc/arch-x86/syscalls/timer_getoverrun.S)6
-rw-r--r--libc/arch-x86/syscalls/__timer_gettime.S (renamed from libc/arch-x86/syscalls/timer_gettime.S)6
-rw-r--r--libc/arch-x86/syscalls/__timer_settime.S (renamed from libc/arch-x86/syscalls/timer_settime.S)6
-rw-r--r--libc/arch-x86/syscalls/accept.S27
-rw-r--r--libc/arch-x86/syscalls/bind.S27
-rw-r--r--libc/arch-x86/syscalls/connect.S27
-rw-r--r--libc/arch-x86/syscalls/getitimer.S26
-rw-r--r--libc/arch-x86/syscalls/getpeername.S27
-rw-r--r--libc/arch-x86/syscalls/getsockname.S27
-rw-r--r--libc/arch-x86/syscalls/getsockopt.S27
-rw-r--r--libc/arch-x86/syscalls/listen.S27
-rw-r--r--libc/arch-x86/syscalls/recvfrom.S27
-rw-r--r--libc/arch-x86/syscalls/recvmsg.S27
-rw-r--r--libc/arch-x86/syscalls/sendmsg.S27
-rw-r--r--libc/arch-x86/syscalls/sendto.S27
-rw-r--r--libc/arch-x86/syscalls/setsockopt.S27
-rw-r--r--libc/arch-x86/syscalls/shutdown.S27
-rw-r--r--libc/arch-x86/syscalls/socket.S27
-rw-r--r--libc/arch-x86/syscalls/socketpair.S27
-rw-r--r--libc/arch-x86/syscalls/vfork.S23
-rw-r--r--libc/bionic/fork.c48
-rw-r--r--libc/bionic/if_indextoname.c63
-rw-r--r--libc/bionic/malloc_leak.c10
-rw-r--r--libc/bionic/pthread-timers.c625
-rw-r--r--libc/bionic/pthread.c85
-rw-r--r--libc/bionic/pthread_internal.h62
-rw-r--r--libc/include/dirent.h5
-rw-r--r--libc/include/features.h58
-rw-r--r--libc/include/grp.h3
-rw-r--r--libc/include/net/if.h1
-rw-r--r--libc/include/netdb.h7
-rw-r--r--libc/include/netinet/in.h1
-rw-r--r--libc/include/netinet/in6.h34
-rw-r--r--libc/include/pthread.h2
-rw-r--r--libc/include/signal.h1
-rw-r--r--libc/include/stdint.h5
-rw-r--r--libc/include/stdio.h8
-rw-r--r--libc/include/stdlib.h26
-rw-r--r--libc/include/sys/_system_properties.h8
-rw-r--r--libc/include/sys/atomics.h1
-rw-r--r--libc/include/sys/linux-syscalls.h6
-rw-r--r--libc/include/sys/linux-unistd.h30
-rw-r--r--libc/include/sys/socket.h2
-rw-r--r--libc/include/sys/timeb.h46
-rw-r--r--libc/include/termios.h13
-rw-r--r--libc/include/time.h1
-rw-r--r--libc/include/unistd.h2
-rw-r--r--libc/include/wchar.h6
-rw-r--r--libc/kernel/README.TXT48
-rw-r--r--libc/kernel/arch-x86/asm/a.out.h31
-rw-r--r--libc/kernel/arch-x86/asm/acpi.h19
-rw-r--r--libc/kernel/arch-x86/asm/acpi_32.h15
-rw-r--r--libc/kernel/arch-x86/asm/alternative.h12
-rw-r--r--libc/kernel/arch-x86/asm/alternative_32.h38
-rw-r--r--libc/kernel/arch-x86/asm/apic.h12
-rw-r--r--libc/kernel/arch-x86/asm/apic_32.h31
-rw-r--r--libc/kernel/arch-x86/asm/apicdef.h12
-rw-r--r--libc/kernel/arch-x86/asm/apicdef_32.h372
-rw-r--r--libc/kernel/arch-x86/asm/atomic.h12
-rw-r--r--libc/kernel/arch-x86/asm/atomic_32.h39
-rw-r--r--libc/kernel/arch-x86/asm/auxvec.h20
-rw-r--r--libc/kernel/arch-x86/asm/bitops.h12
-rw-r--r--libc/kernel/arch-x86/asm/bitops_32.h30
-rw-r--r--libc/kernel/arch-x86/asm/bug.h16
-rw-r--r--libc/kernel/arch-x86/asm/byteorder.h70
-rw-r--r--libc/kernel/arch-x86/asm/cache.h20
-rw-r--r--libc/kernel/arch-x86/asm/cacheflush.h34
-rw-r--r--libc/kernel/arch-x86/asm/cmpxchg.h12
-rw-r--r--libc/kernel/arch-x86/asm/cmpxchg_32.h31
-rw-r--r--libc/kernel/arch-x86/asm/cpufeature.h12
-rw-r--r--libc/kernel/arch-x86/asm/cpufeature_32.h151
-rw-r--r--libc/kernel/arch-x86/asm/cputime.h12
-rw-r--r--libc/kernel/arch-x86/asm/current.h12
-rw-r--r--libc/kernel/arch-x86/asm/current_32.h21
-rw-r--r--libc/kernel/arch-x86/asm/delay.h19
-rw-r--r--libc/kernel/arch-x86/asm/desc.h12
-rw-r--r--libc/kernel/arch-x86/asm/desc_32.h65
-rw-r--r--libc/kernel/arch-x86/asm/desc_defs.h70
-rw-r--r--libc/kernel/arch-x86/asm/div64.h17
-rw-r--r--libc/kernel/arch-x86/asm/dma-mapping.h12
-rw-r--r--libc/kernel/arch-x86/asm/dma-mapping_32.h28
-rw-r--r--libc/kernel/arch-x86/asm/dma.h12
-rw-r--r--libc/kernel/arch-x86/asm/dma_32.h90
-rw-r--r--libc/kernel/arch-x86/asm/dwarf2.h12
-rw-r--r--libc/kernel/arch-x86/asm/dwarf2_32.h33
-rw-r--r--libc/kernel/arch-x86/asm/e820.h36
-rw-r--r--libc/kernel/arch-x86/asm/elf.h74
-rw-r--r--libc/kernel/arch-x86/asm/errno.h12
-rw-r--r--libc/kernel/arch-x86/asm/fcntl.h12
-rw-r--r--libc/kernel/arch-x86/asm/fixmap.h12
-rw-r--r--libc/kernel/arch-x86/asm/fixmap_32.h55
-rw-r--r--libc/kernel/arch-x86/asm/genapic.h12
-rw-r--r--libc/kernel/arch-x86/asm/genapic_32.h73
-rw-r--r--libc/kernel/arch-x86/asm/hardirq.h12
-rw-r--r--libc/kernel/arch-x86/asm/hardirq_32.h36
-rw-r--r--libc/kernel/arch-x86/asm/highmem.h15
-rw-r--r--libc/kernel/arch-x86/asm/hw_irq.h12
-rw-r--r--libc/kernel/arch-x86/asm/hw_irq_32.h24
-rw-r--r--libc/kernel/arch-x86/asm/i387.h12
-rw-r--r--libc/kernel/arch-x86/asm/i387_32.h33
-rw-r--r--libc/kernel/arch-x86/asm/i8253.h19
-rw-r--r--libc/kernel/arch-x86/asm/i8259.h19
-rw-r--r--libc/kernel/arch-x86/asm/ia32_unistd.h22
-rw-r--r--libc/kernel/arch-x86/asm/io.h12
-rw-r--r--libc/kernel/arch-x86/asm/io_32.h27
-rw-r--r--libc/kernel/arch-x86/asm/io_apic.h12
-rw-r--r--libc/kernel/arch-x86/asm/io_apic_32.h96
-rw-r--r--libc/kernel/arch-x86/asm/ioctl.h12
-rw-r--r--libc/kernel/arch-x86/asm/ioctls.h95
-rw-r--r--libc/kernel/arch-x86/asm/ipcbuf.h30
-rw-r--r--libc/kernel/arch-x86/asm/irq.h12
-rw-r--r--libc/kernel/arch-x86/asm/irq_32.h23
-rw-r--r--libc/kernel/arch-x86/asm/irqflags.h12
-rw-r--r--libc/kernel/arch-x86/asm/irqflags_32.h33
-rw-r--r--libc/kernel/arch-x86/asm/ist.h24
-rw-r--r--libc/kernel/arch-x86/asm/kmap_types.h36
-rw-r--r--libc/kernel/arch-x86/asm/ldt.h41
-rw-r--r--libc/kernel/arch-x86/asm/linkage.h12
-rw-r--r--libc/kernel/arch-x86/asm/linkage_32.h21
-rw-r--r--libc/kernel/arch-x86/asm/local.h12
-rw-r--r--libc/kernel/arch-x86/asm/local_32.h51
-rw-r--r--libc/kernel/arch-x86/asm/math_emu.h40
-rw-r--r--libc/kernel/arch-x86/asm/mc146818rtc.h12
-rw-r--r--libc/kernel/arch-x86/asm/mc146818rtc_32.h44
-rw-r--r--libc/kernel/arch-x86/asm/mman.h30
-rw-r--r--libc/kernel/arch-x86/asm/mmsegment.h19
-rw-r--r--libc/kernel/arch-x86/asm/mmu.h25
-rw-r--r--libc/kernel/arch-x86/asm/module.h12
-rw-r--r--libc/kernel/arch-x86/asm/module_32.h29
-rw-r--r--libc/kernel/arch-x86/asm/mpspec.h12
-rw-r--r--libc/kernel/arch-x86/asm/mpspec_32.h52
-rw-r--r--libc/kernel/arch-x86/asm/mpspec_def.h171
-rw-r--r--libc/kernel/arch-x86/asm/msgbuf.h38
-rw-r--r--libc/kernel/arch-x86/asm/msr-index.h283
-rw-r--r--libc/kernel/arch-x86/asm/msr.h54
-rw-r--r--libc/kernel/arch-x86/asm/page.h16
-rw-r--r--libc/kernel/arch-x86/asm/page_32.h22
-rw-r--r--libc/kernel/arch-x86/asm/param.h27
-rw-r--r--libc/kernel/arch-x86/asm/paravirt.h15
-rw-r--r--libc/kernel/arch-x86/asm/pda.h65
-rw-r--r--libc/kernel/arch-x86/asm/percpu.h12
-rw-r--r--libc/kernel/arch-x86/asm/percpu_32.h36
-rw-r--r--libc/kernel/arch-x86/asm/pgalloc.h12
-rw-r--r--libc/kernel/arch-x86/asm/pgalloc_32.h30
-rw-r--r--libc/kernel/arch-x86/asm/pgtable-2level-defs.h22
-rw-r--r--libc/kernel/arch-x86/asm/pgtable-2level.h39
-rw-r--r--libc/kernel/arch-x86/asm/pgtable.h12
-rw-r--r--libc/kernel/arch-x86/asm/pgtable_32.h175
-rw-r--r--libc/kernel/arch-x86/asm/poll.h12
-rw-r--r--libc/kernel/arch-x86/asm/posix_types.h16
-rw-r--r--libc/kernel/arch-x86/asm/posix_types_32.h70
-rw-r--r--libc/kernel/arch-x86/asm/prctl.h20
-rw-r--r--libc/kernel/arch-x86/asm/processor-flags.h79
-rw-r--r--libc/kernel/arch-x86/asm/processor.h12
-rw-r--r--libc/kernel/arch-x86/asm/processor_32.h324
-rw-r--r--libc/kernel/arch-x86/asm/ptrace-abi.h88
-rw-r--r--libc/kernel/arch-x86/asm/ptrace.h74
-rw-r--r--libc/kernel/arch-x86/asm/required-features.h44
-rw-r--r--libc/kernel/arch-x86/asm/resource.h12
-rw-r--r--libc/kernel/arch-x86/asm/rwlock.h18
-rw-r--r--libc/kernel/arch-x86/asm/scatterlist.h12
-rw-r--r--libc/kernel/arch-x86/asm/scatterlist_32.h31
-rw-r--r--libc/kernel/arch-x86/asm/sections.h12
-rw-r--r--libc/kernel/arch-x86/asm/segment.h12
-rw-r--r--libc/kernel/arch-x86/asm/segment_32.h89
-rw-r--r--libc/kernel/arch-x86/asm/semaphore.h12
-rw-r--r--libc/kernel/arch-x86/asm/semaphore_32.h17
-rw-r--r--libc/kernel/arch-x86/asm/sembuf.h26
-rw-r--r--libc/kernel/arch-x86/asm/setup.h17
-rw-r--r--libc/kernel/arch-x86/asm/shmbuf.h49
-rw-r--r--libc/kernel/arch-x86/asm/shmparam.h17
-rw-r--r--libc/kernel/arch-x86/asm/sigcontext.h132
-rw-r--r--libc/kernel/arch-x86/asm/siginfo.h21
-rw-r--r--libc/kernel/arch-x86/asm/signal.h127
-rw-r--r--libc/kernel/arch-x86/asm/smp.h12
-rw-r--r--libc/kernel/arch-x86/asm/smp_32.h34
-rw-r--r--libc/kernel/arch-x86/asm/socket.h63
-rw-r--r--libc/kernel/arch-x86/asm/sockios.h23
-rw-r--r--libc/kernel/arch-x86/asm/spinlock.h12
-rw-r--r--libc/kernel/arch-x86/asm/spinlock_32.h29
-rw-r--r--libc/kernel/arch-x86/asm/spinlock_types.h31
-rw-r--r--libc/kernel/arch-x86/asm/stat.h120
-rw-r--r--libc/kernel/arch-x86/asm/statfs.h62
-rw-r--r--libc/kernel/arch-x86/asm/string.h12
-rw-r--r--libc/kernel/arch-x86/asm/string_32.h15
-rw-r--r--libc/kernel/arch-x86/asm/swiotlb.h19
-rw-r--r--libc/kernel/arch-x86/asm/system.h12
-rw-r--r--libc/kernel/arch-x86/asm/system_32.h33
-rw-r--r--libc/kernel/arch-x86/asm/termbits.h201
-rw-r--r--libc/kernel/arch-x86/asm/termios.h50
-rw-r--r--libc/kernel/arch-x86/asm/thread_info.h12
-rw-r--r--libc/kernel/arch-x86/asm/thread_info_32.h15
-rw-r--r--libc/kernel/arch-x86/asm/tlbflush.h12
-rw-r--r--libc/kernel/arch-x86/asm/tlbflush_32.h43
-rw-r--r--libc/kernel/arch-x86/asm/tsc.h22
-rw-r--r--libc/kernel/arch-x86/asm/types.h40
-rw-r--r--libc/kernel/arch-x86/asm/uaccess.h12
-rw-r--r--libc/kernel/arch-x86/asm/uaccess_32.h83
-rw-r--r--libc/kernel/arch-x86/asm/unaligned.h19
-rw-r--r--libc/kernel/arch-x86/asm/unistd.h16
-rw-r--r--libc/kernel/arch-x86/asm/unistd_32.h341
-rw-r--r--libc/kernel/arch-x86/asm/user.h16
-rw-r--r--libc/kernel/arch-x86/asm/user32.h73
-rw-r--r--libc/kernel/arch-x86/asm/user_32.h81
-rw-r--r--libc/kernel/arch-x86/asm/vm86.h113
-rw-r--r--libc/kernel/arch-x86/asm/voyager.h437
-rw-r--r--libc/kernel/arch-x86/asm/vsyscall.h27
-rw-r--r--libc/kernel/arch-x86/asm/xen/hypercall.h34
-rw-r--r--libc/kernel/common/asm-generic/poll.h46
-rw-r--r--libc/kernel/common/linux/android_alarm.h1
-rw-r--r--libc/kernel/common/linux/msm_mdp.h1
-rw-r--r--libc/kernel/tools/cpp.py2
-rw-r--r--libc/kernel/tools/defaults.py7
-rw-r--r--libc/kernel/tools/kernel.py40
-rw-r--r--libc/netbsd/net/getnameinfo.c10
-rw-r--r--libc/stdio/fclose.c4
-rw-r--r--libc/stdio/flockfile.c212
-rw-r--r--libc/stdlib/div.c71
-rw-r--r--libc/stdlib/ldiv.c50
-rw-r--r--libc/stdlib/lldiv.c50
-rw-r--r--libc/tools/bionic_utils.py23
-rwxr-xr-xlibc/tools/gensyscalls.py85
-rw-r--r--libc/unistd/ftime.c49
-rw-r--r--libc/unistd/initgroups.c58
-rw-r--r--libc/unistd/opendir.c62
-rw-r--r--libc/unistd/pread.c45
-rw-r--r--libc/unistd/pwrite.c22
-rw-r--r--libc/unistd/siginterrupt.c45
-rw-r--r--libc/unistd/tcgetpgrp.c34
-rw-r--r--libc/unistd/tcsetpgrp.c33
-rw-r--r--libc/zoneinfo/Android.mk4
-rw-r--r--libc/zoneinfo/zoneinfo.datbin175024 -> 169880 bytes
-rw-r--r--libc/zoneinfo/zoneinfo.idxbin23348 -> 29016 bytes
-rw-r--r--libc/zoneinfo/zoneinfo.version1
-rw-r--r--libdl/Android.mk8
-rw-r--r--libdl/libdl.c10
-rw-r--r--libm/Android.mk36
-rw-r--r--libm/i387/fenv.c2
-rw-r--r--libm/i387/npx.h160
-rw-r--r--libm/src/e_ldexpf.c22
-rw-r--r--libm/src/math_private.h1
-rw-r--r--libstdc++/include/stl_pair.h (renamed from libc/include/stl_pair.h)2
-rw-r--r--libstdc++/include/utility (renamed from libc/include/utility)0
-rw-r--r--linker/debugger.c20
-rw-r--r--linker/linker.c32
-rw-r--r--linker/linker_debug.h10
287 files changed, 11495 insertions, 341 deletions
diff --git a/libc/Android.mk b/libc/Android.mk
index faca333..57919ad 100644
--- a/libc/Android.mk
+++ b/libc/Android.mk
@@ -1,6 +1,6 @@
LOCAL_PATH:= $(call my-dir)
-include $(LOCAL_PATH)/arch-arm/syscalls.mk
+include $(LOCAL_PATH)/arch-$(TARGET_ARCH)/syscalls.mk
libc_common_src_files := \
$(syscall_src) \
unistd/abort.c \
@@ -11,6 +11,7 @@ libc_common_src_files := \
unistd/exec.c \
unistd/fcntl.c \
unistd/fnmatch.c \
+ unistd/ftime.c \
unistd/ftok.c \
unistd/getcwd.c \
unistd/getdtablesize.c \
@@ -19,6 +20,7 @@ libc_common_src_files := \
unistd/getpgrp.c \
unistd/getpriority.c \
unistd/getpt.c \
+ unistd/initgroups.c \
unistd/isatty.c \
unistd/issetugid.c \
unistd/lseek64.c \
@@ -44,18 +46,20 @@ libc_common_src_files := \
unistd/seteuid.c \
unistd/setpgrp.c \
unistd/sigblock.c \
+ unistd/siginterrupt.c \
unistd/siglist.c \
unistd/signal.c \
unistd/sigsetmask.c \
unistd/sigsuspend.c \
unistd/sigwait.c \
unistd/sleep.c \
- unistd/socketcalls.c \
unistd/statfs.c \
unistd/strsignal.c \
unistd/sysconf.c \
unistd/syslog.c \
unistd/system.c \
+ unistd/tcgetpgrp.c \
+ unistd/tcsetpgrp.c \
unistd/time.c \
unistd/umount.c \
unistd/unlockpt.c \
@@ -74,6 +78,7 @@ libc_common_src_files := \
stdio/fileno.c \
stdio/findfp.c \
stdio/flags.c \
+ stdio/flockfile.c \
stdio/fopen.c \
stdio/fprintf.c \
stdio/fpurge.c \
@@ -122,6 +127,7 @@ libc_common_src_files := \
stdio/vsnprintf.c \
stdio/vsprintf.c \
stdio/vscanf.c \
+ stdio/vsscanf.c \
stdio/wbuf.c \
stdio/wsetup.c \
stdlib/_rand48.c \
@@ -132,9 +138,12 @@ libc_common_src_files := \
stdlib/atoll.c \
stdlib/bsearch.c \
stdlib/ctype_.c \
+ stdlib/div.c \
stdlib/exit.c \
stdlib/getenv.c \
stdlib/jrand48.c \
+ stdlib/ldiv.c \
+ stdlib/lldiv.c \
stdlib/locale.c \
stdlib/lrand48.c \
stdlib/mrand48.c \
@@ -200,22 +209,6 @@ libc_common_src_files := \
tzcode/localtime.c \
tzcode/strftime.c \
tzcode/strptime.c \
- arch-arm/bionic/__get_pc.S \
- arch-arm/bionic/__get_sp.S \
- arch-arm/bionic/_exit_with_stack_teardown.S \
- arch-arm/bionic/_setjmp.S \
- arch-arm/bionic/atomics_arm.S \
- arch-arm/bionic/clone.S \
- arch-arm/bionic/memcmp.S \
- arch-arm/bionic/memcmp16.S \
- arch-arm/bionic/memcpy.S \
- arch-arm/bionic/memset.S \
- arch-arm/bionic/setjmp.S \
- arch-arm/bionic/sigsetjmp.S \
- arch-arm/bionic/strlen.c.arm \
- arch-arm/bionic/syscall.S \
- arch-arm/bionic/kill.S \
- arch-arm/bionic/tkill.S \
bionic/__errno.c \
bionic/__set_errno.c \
bionic/_rand48.c \
@@ -225,9 +218,10 @@ libc_common_src_files := \
bionic/dirname.c \
bionic/dirname_r.c \
bionic/drand48.c \
- bionic/eabi.c \
bionic/erand48.c \
+ bionic/fork.c \
bionic/if_nametoindex.c \
+ bionic/if_indextoname.c \
bionic/ioctl.c \
bionic/ldexp.c \
bionic/libc_init_common.c \
@@ -274,12 +268,58 @@ libc_common_src_files := \
netbsd/nameser/ns_print.c \
netbsd/nameser/ns_samedomain.c
+ifeq ($(TARGET_ARCH),arm)
+libc_common_src_files += \
+ bionic/eabi.c \
+ arch-arm/bionic/__get_pc.S \
+ arch-arm/bionic/__get_sp.S \
+ arch-arm/bionic/_exit_with_stack_teardown.S \
+ arch-arm/bionic/_setjmp.S \
+ arch-arm/bionic/atomics_arm.S \
+ arch-arm/bionic/clone.S \
+ arch-arm/bionic/kill.S \
+ arch-arm/bionic/tkill.S \
+ arch-arm/bionic/memcmp.S \
+ arch-arm/bionic/memcmp16.S \
+ arch-arm/bionic/memcpy.S \
+ arch-arm/bionic/memset.S \
+ arch-arm/bionic/setjmp.S \
+ arch-arm/bionic/sigsetjmp.S \
+ arch-arm/bionic/strlen.c.arm \
+ arch-arm/bionic/syscall.S \
+ unistd/socketcalls.c
+
# These files need to be arm so that gdbserver
# can set breakpoints in them without messing
# up any thumb code.
libc_common_src_files += \
bionic/pthread.c.arm \
+ bionic/pthread-timers.c.arm \
bionic/ptrace.c.arm
+else # !arm
+
+ifeq ($(TARGET_ARCH),x86)
+libc_common_src_files += \
+ arch-x86/bionic/__get_sp.S \
+ arch-x86/bionic/__get_tls.c \
+ arch-x86/bionic/__set_tls.c \
+ arch-x86/bionic/atomics_x86.S \
+ arch-x86/bionic/clone.S \
+ arch-x86/bionic/_exit_with_stack_teardown.S \
+ arch-x86/bionic/setjmp.S \
+ arch-x86/bionic/_setjmp.S \
+ arch-x86/bionic/vfork.S \
+ arch-x86/string/bzero.S \
+ arch-x86/string/memset.S \
+ arch-x86/string/memcmp.S \
+ arch-x86/string/memcpy.S \
+ arch-x86/string/strlen.S \
+ bionic/pthread.c \
+ bionic/pthread-timers.c \
+ bionic/ptrace.c
+endif # x86
+
+endif # !arm
libc_common_cflags := \
-DWITH_ERRLIST \
@@ -289,7 +329,8 @@ libc_common_cflags := \
-D_LIBC=1 \
-DSOFTFLOAT \
-DFLOATING_POINT \
- -DNEED_PSELECT=1
+ -DNEED_PSELECT=1 \
+ -DINET6
ifeq ($(TARGET_BUILD_TYPE),debug)
libc_common_cflags += -DDEBUG
@@ -313,13 +354,48 @@ LOCAL_SRC_FILES := $(libc_common_src_files)
LOCAL_CFLAGS := $(libc_common_cflags) -DUSE_DL_PREFIX
LOCAL_C_INCLUDES := $(libc_common_c_includes)
+ifneq ($(TARGET_SIMULATOR),true)
+ ifeq ($(TARGET_ARCH),arm)
+ crtend_target_cflags := -mthumb-interwork
+ else
+ ifeq ($(TARGET_ARCH),x86)
+ crtend_target_cflags := -m32
+ endif
+ endif
# We rename crtend.o to crtend_android.o to avoid a
# name clash between gcc and bionic.
GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_android.o
-$(GEN): $(LOCAL_PATH)/arch-arm/bionic/crtend.S
+$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend.S
@mkdir -p $(dir $@)
- $(TARGET_CC) -mthumb-interwork -o $@ -c $<
+ $(TARGET_CC) $(crtend_target_cflags) -o $@ -c $<
ALL_GENERATED_SOURCES += $(GEN)
+endif
+
+
+# crtbegin_so.o/crtend_so.o
+# These are needed for building the shared libs.
+ifneq ($(TARGET_SIMULATOR),true)
+
+ifeq ($(TARGET_ARCH),x86)
+
+crt_begin_end_so_target_cflags := -m32
+
+GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o
+$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.S
+ @mkdir -p $(dir $@)
+ $(TARGET_CC) $(crt_begin_end_so_target_cflags) -o $@ -c $<
+ALL_GENERATED_SOURCES += $(GEN)
+
+GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtend_so.o
+$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtend_so.S
+ @mkdir -p $(dir $@)
+ $(TARGET_CC) $(crt_begin_end_so_target_cflags) -o $@ -c $<
+ALL_GENERATED_SOURCES += $(GEN)
+
+endif # TARGET_ARCH == x86
+
+endif # !TARGET_SIMULATOR
+
LOCAL_MODULE := libc_common
LOCAL_SYSTEM_SHARED_LIBRARIES :=
@@ -332,7 +408,7 @@ include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
-include $(LOCAL_PATH)/arch-arm/syscalls.mk
+include $(LOCAL_PATH)/arch-$(TARGET_ARCH)/syscalls.mk
# To enable malloc leak check for statically linked programs, add
# "WITH_MALLOC_CHECK_LIBC_A := true" to device/buildspec.mk
@@ -341,18 +417,39 @@ WITH_MALLOC_CHECK_LIBC_A := $(strip $(WITH_MALLOC_CHECK_LIBC_A))
LOCAL_SRC_FILES := \
$(libc_common_src_files) \
bionic/dlmalloc.c \
- arch-arm/bionic/exidx_static.c \
bionic/libc_init_static.c
ifeq ($(WITH_MALLOC_CHECK_LIBC_A),true)
LOCAL_SRC_FILES += bionic/malloc_leak.c.arm
endif
+ifeq ($(TARGET_ARCH),arm)
+LOCAL_SRC_FILES += \
+ arch-arm/bionic/exidx_static.c
+
+else # TARGET_ARCH != arm
+
+ifeq ($(TARGET_ARCH),x86)
+LOCAL_SRC_FILES += \
+ arch-x86/bionic/dl_iterate_phdr_static.c
+endif
+
+endif
+
+ifneq ($(TARGET_SIMULATOR),true)
+ ifeq ($(TARGET_ARCH),arm)
+ crtbegin_static_target_cflags := -mthumb-interwork
+ else
+ ifeq ($(TARGET_ARCH),x86)
+ crtbegin_static_target_cflags := -m32
+ endif
+ endif
GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_static.o
-$(GEN): $(LOCAL_PATH)/arch-arm/bionic/crtbegin_static.S
+$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_static.S
@mkdir -p $(dir $@)
- $(TARGET_CC) -mthumb-interwork -o $@ -c $<
+ $(TARGET_CC) $(crtbegin_static_target_cflags) -o $@ -c $<
ALL_GENERATED_SOURCES += $(GEN)
+endif
LOCAL_CFLAGS := $(libc_common_cflags)
@@ -383,9 +480,13 @@ LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_SRC_FILES := \
bionic/dlmalloc.c \
bionic/malloc_leak.c.arm \
- arch-arm/bionic/exidx_dynamic.c \
bionic/libc_init_dynamic.c
+ifeq ($(TARGET_ARCH),arm)
+LOCAL_SRC_FILES += \
+ arch-arm/bionic/exidx_dynamic.c
+endif
+
LOCAL_MODULE:= libc
# WARNING: The only library libc.so should depend on is libdl.so! If you add other libraries,
@@ -400,11 +501,20 @@ LOCAL_SHARED_LIBRARIES := libdl
LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
LOCAL_SYSTEM_SHARED_LIBRARIES :=
+ifneq ($(TARGET_SIMULATOR),true)
+ ifeq ($(TARGET_ARCH),arm)
+ crtbegin_dynamic_target_cflags := -mthumb-interwork
+ else
+ ifeq ($(TARGET_ARCH),x86)
+ crtbegin_dynamic_target_cflags := -m32
+ endif
+ endif
GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_dynamic.o
-$(GEN): $(LOCAL_PATH)/arch-arm/bionic/crtbegin_dynamic.S
+$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_dynamic.S
@mkdir -p $(dir $@)
- $(TARGET_CC) -mthumb-interwork -o $@ -c $<
+ $(TARGET_CC) $(crtbegin_dynamic_target_cflags) -o $@ -c $<
ALL_GENERATED_SOURCES += $(GEN)
+endif
include $(BUILD_SHARED_LIBRARY)
@@ -423,9 +533,13 @@ LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_SRC_FILES := \
bionic/dlmalloc.c \
bionic/malloc_leak.c.arm \
- arch-arm/bionic/exidx_dynamic.c \
bionic/libc_init_dynamic.c
+ifeq ($(TARGET_ARCH),arm)
+LOCAL_SRC_FILES += \
+ arch-arm/bionic/exidx_dynamic.c
+endif
+
LOCAL_MODULE:= libc_debug
# WARNING: The only library libc.so should depend on is libdl.so! If you add other libraries,
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index 723a880..0445fc9 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -4,12 +4,16 @@
#
# each non comment line has the following format:
#
-# return_type func_name[:syscall_name]([parameter_list]) (#syscall_number|stub)
+# return_type func_name[:syscall_name[:call_id]]([parameter_list]) (#syscall_number|stub)
#
# note that:
# - syscall_name correspond to the name of the syscall, which may differ from
# the exported function name (example: the exit syscall is implemented by the _exit()
# function, which is not the same as the standard C exit() function which calls it)
+# The call_id parameter, given that func_name and syscall_name have
+# been provided, allows the user to specify dispatch style syscalls.
+# For example, socket() syscall on i386 actually becomes:
+# socketcall(__NR_socket, 1, *(rest of args on stack)).
#
# - each parameter type is assumed to be stored on 32 bits, there is no plan to support
# 64-bit architectures at the moment
@@ -24,7 +28,7 @@
# process management
void _exit:exit_group (int) 248,252
void _exit_thread:exit (int) 1
-int fork (void) 2
+pid_t __fork:fork (void) 2
pid_t _waitpid:waitpid (pid_t, int*, int, struct rusage*) -1,7
int waitid(int, pid_t, struct siginfo_t*, int,void*) 280,284
pid_t __clone:clone(int (*fn)(void*), void *child_stack, int flags, void *arg) 120
@@ -61,7 +65,7 @@ int getrusage(int who, struct rusage* r_usage) 77
int setgroups:setgroups32(int, const gid_t *) 206
pid_t getpgrp(void) stub
int setpgid(pid_t, pid_t) 57
-pid_t vfork(void) 190
+pid_t vfork(void) 190,-1
int setregid:setregid32(gid_t, gid_t) 204
int chroot(const char *) 61
int prctl(int option, unsigned int arg2, unsigned int arg3, unsigned int arg4, unsigned int arg5) 172
@@ -72,6 +76,8 @@ int acct(const char* filepath) 51
# file descriptors
ssize_t read (int, void*, size_t) 3
ssize_t write (int, const void*, size_t) 4
+ssize_t __pread64:pread64 (int, void *, size_t, off_t, off_t) 180
+ssize_t __pwrite64:pwrite64 (int, void *, size_t, off_t, off_t) 181
int __open:open (const char*, int, mode_t) 5
int __openat:openat (int, const char*, int, mode_t) 322,295
int close (int) 6
@@ -148,12 +154,13 @@ int clock_gettime(clockid_t clk_id, struct timespec *tp) 263,265
int clock_settime(clockid_t clk_id, const struct timespec *tp) 262,264
int clock_getres(clockid_t clk_id, struct timespec *res) 264,266
int clock_nanosleep(const struct timespec *req, struct timespec *rem) 265,267
+int getitimer(int, const struct itimerval *) 105
int setitimer(int, const struct itimerval *, struct itimerval *) 104
-int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid) 257,259
-int timer_settime(timer_t, int, const struct itimerspec*, struct itimerspec*) 258,260
-int timer_gettime(timer_t, struct itimerspec*) 259,261
-int timer_getoverrun(timer_t) 260,262
-int timer_delete(timer_t) 261,263
+int __timer_create:timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid) 257,259
+int __timer_settime:timer_settime(timer_t, int, const struct itimerspec*, struct itimerspec*) 258,260
+int __timer_gettime:timer_gettime(timer_t, struct itimerspec*) 259,261
+int __timer_getoverrun:timer_getoverrun(timer_t) 260,262
+int __timer_delete:timer_delete(timer_t) 261,263
int utimes(const char*, const struct timeval tvp[2]) 269, 271
# signals
@@ -182,6 +189,23 @@ int getsockopt(int, int, int, void *, socklen_t *) 295,-1
int sendmsg(int, const struct msghdr *, unsigned int) 296,-1
int recvmsg(int, struct msghdr *, unsigned int) 297,-1
+# sockets for x86. These are done as an "indexed" call to socketcall syscall.
+int socket:socketcall:1 (int, int, int) -1,102
+int bind:socketcall:2 (int, struct sockaddr *, int) -1,102
+int connect:socketcall:3(int, struct sockaddr *, socklen_t) -1,102
+int listen:socketcall:4(int, int) -1,102
+int accept:socketcall:5(int, struct sockaddr *, socklen_t *) -1,102
+int getsockname:socketcall:6(int, struct sockaddr *, socklen_t *) -1,102
+int getpeername:socketcall:7(int, struct sockaddr *, socklen_t *) -1,102
+int socketpair:socketcall:8(int, int, int, int*) -1,102
+int sendto:socketcall:11(int, const void *, size_t, int, const struct sockaddr *, socklen_t) -1,102
+int recvfrom:socketcall:12(int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *) -1,102
+int shutdown:socketcall:13(int, int) -1,102
+int setsockopt:socketcall:14(int, int, int, const void *, socklen_t) -1,102
+int getsockopt:socketcall:15(int, int, int, void *, socklen_t *) -1,102
+int sendmsg:socketcall:16(int, const struct msghdr *, unsigned int) -1,102
+int recvmsg:socketcall:17(int, struct msghdr *, unsigned int) -1,102
+
# scheduler & real-time
int sched_setscheduler(pid_t pid, int policy, const struct sched_param *param) 156
int sched_getscheduler(pid_t pid) 157
diff --git a/libc/arch-arm/bionic/memcmp.S b/libc/arch-arm/bionic/memcmp.S
index d19dfb9..f45b56b 100644
--- a/libc/arch-arm/bionic/memcmp.S
+++ b/libc/arch-arm/bionic/memcmp.S
@@ -25,6 +25,9 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
+#include <machine/cpu-features.h>
+
.text
.global memcmp
@@ -41,8 +44,8 @@
*/
memcmp:
- pld [r0, #0]
- pld [r1, #0]
+ PLD (r0, #0)
+ PLD (r1, #0)
/* take of the case where length is 0 or the buffers are the same */
cmp r0, r1
@@ -53,8 +56,8 @@ memcmp:
/* save registers */
stmfd sp!, {r4, lr}
- pld [r0, #32]
- pld [r1, #32]
+ PLD (r0, #32)
+ PLD (r1, #32)
/* since r0 hold the result, move the first source
* pointer somewhere else
@@ -104,8 +107,8 @@ memcmp:
subs r2, r2, #(32 + 4)
bmi 1f
-0: pld [r4, #64]
- pld [r1, #64]
+0: PLD (r4, #64)
+ PLD (r1, #64)
ldr r0, [r4], #4
ldr lr, [r1, #4]!
eors r0, r0, ip
@@ -192,8 +195,8 @@ memcmp:
bic r1, r1, #3
ldr lr, [r1], #4
-6: pld [r1, #64]
- pld [r4, #64]
+6: PLD (r1, #64)
+ PLD (r4, #64)
mov ip, lr, lsr #16
ldr lr, [r1], #4
ldr r0, [r4], #4
diff --git a/libc/arch-arm/bionic/memcmp16.S b/libc/arch-arm/bionic/memcmp16.S
index c6e6d39..38d8b62 100644
--- a/libc/arch-arm/bionic/memcmp16.S
+++ b/libc/arch-arm/bionic/memcmp16.S
@@ -25,6 +25,9 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
+#include <machine/cpu-features.h>
+
.text
.global __memcmp16
@@ -41,8 +44,8 @@
*/
__memcmp16:
- pld [r0, #0]
- pld [r1, #0]
+ PLD (r0, #0)
+ PLD (r1, #0)
/* take of the case where length is nul or the buffers are the same */
cmp r0, r1
@@ -64,8 +67,8 @@ __memcmp16:
bpl 0f
/* small blocks (less then 12 words) */
- pld [r0, #32]
- pld [r1, #32]
+ PLD (r0, #32)
+ PLD (r1, #32)
1: ldrh r0, [r3], #2
ldrh ip, [r1], #2
@@ -113,8 +116,8 @@ __memcmp16:
bmi 1f
0:
- pld [r3, #64]
- pld [r1, #64]
+ PLD (r3, #64)
+ PLD (r1, #64)
ldr r0, [r3], #4
ldr lr, [r1, #4]!
eors r0, r0, ip
@@ -195,8 +198,8 @@ __memcmp16:
sub r2, r2, #8
6:
- pld [r3, #64]
- pld [r1, #64]
+ PLD (r3, #64)
+ PLD (r1, #64)
mov ip, lr, lsr #16
ldr lr, [r1], #4
ldr r0, [r3], #4
diff --git a/libc/arch-arm/bionic/memcpy.S b/libc/arch-arm/bionic/memcpy.S
index f6e4a7d..fcb58cd 100644
--- a/libc/arch-arm/bionic/memcpy.S
+++ b/libc/arch-arm/bionic/memcpy.S
@@ -25,6 +25,9 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
+#include <machine/cpu-features.h>
+
.text
.global memcpy
@@ -52,9 +55,9 @@ memcpy:
// preload the destination because we'll align it to a cache line
// with small writes. Also start the source "pump".
- pld [r0, #0]
- pld [r1, #0]
- pld [r1, #32]
+ PLD (r0, #0)
+ PLD (r1, #0)
+ PLD (r1, #32)
/* it simplifies things to take care of len<4 early */
cmp r2, #4
@@ -141,8 +144,8 @@ cached_aligned32:
bic r12, r1, #0x1F
add r12, r12, #64
-1: ldmia r1!, { r4-r11 }
- pld [r12, #64]
+1: ldmia r1!, { r4-r11 }
+ PLD (r12, #64)
subs r2, r2, #32
// NOTE: if r12 is more than 64 ahead of r1, the following ldrhi
@@ -263,8 +266,8 @@ loop16:
ldr r12, [r1], #4
1: mov r4, r12
ldmia r1!, { r5,r6,r7, r8,r9,r10,r11}
- pld [r1, #64]
- subs r2, r2, #32
+ PLD (r1, #64)
+ subs r2, r2, #32
ldrhs r12, [r1], #4
orr r3, r3, r4, lsl #16
mov r4, r4, lsr #16
@@ -290,7 +293,7 @@ loop8:
ldr r12, [r1], #4
1: mov r4, r12
ldmia r1!, { r5,r6,r7, r8,r9,r10,r11}
- pld [r1, #64]
+ PLD (r1, #64)
subs r2, r2, #32
ldrhs r12, [r1], #4
orr r3, r3, r4, lsl #24
@@ -317,7 +320,7 @@ loop24:
ldr r12, [r1], #4
1: mov r4, r12
ldmia r1!, { r5,r6,r7, r8,r9,r10,r11}
- pld [r1, #64]
+ PLD (r1, #64)
subs r2, r2, #32
ldrhs r12, [r1], #4
orr r3, r3, r4, lsl #8
diff --git a/libc/arch-arm/bionic/strlen.c b/libc/arch-arm/bionic/strlen.c
index 3d1fe45..01632e3 100644
--- a/libc/arch-arm/bionic/strlen.c
+++ b/libc/arch-arm/bionic/strlen.c
@@ -27,6 +27,7 @@
*/
#include <string.h>
#include <stdint.h>
+#include <machine/cpu-features.h>
size_t strlen(const char *s)
{
@@ -62,7 +63,9 @@ size_t strlen(const char *s)
"ldr %[v], [ %[s] ], #4 \n"
"sub %[l], %[l], %[s] \n"
"0: \n"
+#if __ARM_HAVE_PLD
"pld [ %[s], #64 ] \n"
+#endif
"sub %[t], %[v], %[mask], lsr #7\n"
"and %[t], %[t], %[mask] \n"
"bics %[t], %[t], %[v] \n"
diff --git a/libc/arch-arm/include/asm b/libc/arch-arm/include/asm
deleted file mode 120000
index f9487fd..0000000
--- a/libc/arch-arm/include/asm
+++ /dev/null
@@ -1 +0,0 @@
-/tmp/bionic-kernel-headers/asm-arm \ No newline at end of file
diff --git a/libc/arch-arm/include/machine/_types.h b/libc/arch-arm/include/machine/_types.h
index cf3f027..6d10e12 100644
--- a/libc/arch-arm/include/machine/_types.h
+++ b/libc/arch-arm/include/machine/_types.h
@@ -118,4 +118,10 @@ typedef int __rune_t;
typedef void * __wctrans_t;
typedef void * __wctype_t;
+#ifdef __ARMEB__
+#define _BYTE_ORDER _BIG_ENDIAN
+#else
+#define _BYTE_ORDER _LITTLE_ENDIAN
+#endif
+
#endif /* _ARM__TYPES_H_ */
diff --git a/libc/arch-arm/include/machine/cpu-features.h b/libc/arch-arm/include/machine/cpu-features.h
new file mode 100644
index 0000000..f836006
--- /dev/null
+++ b/libc/arch-arm/include/machine/cpu-features.h
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * 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.
+ *
+ * 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
+ * COPYRIGHT OWNER 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.
+ */
+#ifndef _ARM_MACHINE_CPU_FEATURES_H
+#define _ARM_MACHINE_CPU_FEATURES_H
+
+/* The purpose of this file is to define several macros corresponding
+ * to CPU features that may or may not be available at build time on
+ * on the target CPU.
+ *
+ * This is done to abstract us from the various ARM Architecture
+ * quirks and alphabet soup.
+ *
+ * IMPORTANT: We have no intention to support anything below an ARMv4T !
+ */
+
+/* _ARM_ARCH_REVISION is a number corresponding to the ARM revision
+ * we're going to support
+ *
+ * it looks like our toolchain doesn't define __ARM_ARCH__
+ * so try to guess it.
+ *
+ *
+ *
+ */
+#ifndef __ARM_ARCH__
+
+# if defined __ARM_ARCH_7__ || defined __ARM_ARCH_7A__ || \
+ defined __ARM_ARCH_7R__ || defined __ARM_ARCH_7M__
+
+# define __ARM_ARCH__ 7
+
+# elif defined __ARM_ARCH_6__ || defined __ARM_ARCH_6J__ || \
+ defined __ARM_ARCH_6K__ || defined __ARM_ARCH_6Z__ || \
+ defined __ARM_ARCH_6KZ__ || defined __ARM_ARCH_6T2__
+#
+# define __ARM_ARCH__ 6
+#
+# elif defined __ARM_ARCH_5__ || defined __ARM_ARCH_5T__ || \
+ defined __ARM_ARCH_5TE__ || defined __ARM_ARCH_5TEJ__
+#
+# define __ARM_ARCH__ 5
+#
+# elif defined __ARM_ARCH_4T__
+#
+# define __ARM_ARCH__ 4
+#
+# elif defined __ARM_ARCH_4__
+# error ARMv4 is not supported, please use ARMv4T at a minimum
+# else
+# error Unknown or unsupported ARM architecture
+# endif
+#endif
+
+/* experimental feature used to check that our ARMv4 workarounds
+ * work correctly without a real ARMv4 machine */
+#ifdef BIONIC_EXPERIMENTAL_FORCE_ARMV4
+# undef __ARM_ARCH__
+# define __ARM_ARCH__ 4
+#endif
+
+/* define __ARM_HAVE_5TE if we have the ARMv5TE instructions */
+#if __ARM_ARCH__ > 5
+# define __ARM_HAVE_5TE 1
+#elif __ARM_ARCH__ == 5
+# if defined __ARM_ARCH_5TE__ || defined __ARM_ARCH_5TEJ__
+# define __ARM_HAVE_5TE 1
+# endif
+#endif
+
+/* instructions introduced in ARMv5 */
+#if __ARM_ARCH__ >= 5
+# define __ARM_HAVE_BLX 1
+# define __ARM_HAVE_CLZ 1
+# define __ARM_HAVE_LDC2 1
+# define __ARM_HAVE_MCR2 1
+# define __ARM_HAVE_MRC2 1
+# define __ARM_HAVE_STC2 1
+#endif
+
+/* ARMv5TE introduces a few instructions */
+#if __ARM_HAVE_5TE
+# define __ARM_HAVE_PLD 1
+# define __ARM_HAVE_MCRR 1
+# define __ARM_HAVE_MRRC 1
+#endif
+
+/* define __ARM_HAVE_HALFWORD_MULTIPLY when half-word multiply instructions
+ * this means variants of: smul, smulw, smla, smlaw, smlal
+ */
+#if __ARM_HAVE_5TE
+# define __ARM_HAVE_HALFWORD_MULTIPLY 1
+#endif
+
+/* define __ARM_HAVE_PAIR_LOAD_STORE when 64-bit memory loads and stored
+ * into/from a pair of 32-bit registers is supported throuhg 'ldrd' and 'strd'
+ */
+#if __ARM_HAVE_5TE
+# define __ARM_HAVE_PAIR_LOAD_STORE 1
+#endif
+
+/* define __ARM_HAVE_SATURATED_ARITHMETIC is you have the saturated integer
+ * arithmetic instructions: qdd, qdadd, qsub, qdsub
+ */
+#if __ARM_HAVE_5TE
+# define __ARM_HAVE_SATURATED_ARITHMETIC 1
+#endif
+
+/* define __ARM_HAVE_PC_INTERWORK when a direct assignment to the
+ * pc register will switch into thumb/ARM mode depending on bit 0
+ * of the new instruction address. Before ARMv5, this was not the
+ * case, and you have to write:
+ *
+ * mov r0, [<some address>]
+ * bx r0
+ *
+ * instead of:
+ *
+ * ldr pc, [<some address>]
+ *
+ * note that this affects any instruction that explicitely changes the
+ * value of the pc register, including ldm { ...,pc } or 'add pc, #offset'
+ */
+#if __ARM_ARCH__ >= 5
+# define __ARM_HAVE_PC_INTERWORK
+#endif
+
+
+/* Assembly-only macros */
+
+/* define a handy PLD(address) macro since the cache preload
+ * is an optional opcode
+ */
+#if __ARM_HAVE_PLD
+# define PLD(reg,offset) pld [reg, offset]
+#else
+# define PLD(reg,offset) /* nothing */
+#endif
+
+#endif /* _ARM_MACHINE_CPU_FEATURES_H */
diff --git a/libc/arch-arm/syscalls.mk b/libc/arch-arm/syscalls.mk
index 0a1ef5b..a140a59 100644
--- a/libc/arch-arm/syscalls.mk
+++ b/libc/arch-arm/syscalls.mk
@@ -2,7 +2,7 @@
syscall_src :=
syscall_src += arch-arm/syscalls/_exit.S
syscall_src += arch-arm/syscalls/_exit_thread.S
-syscall_src += arch-arm/syscalls/fork.S
+syscall_src += arch-arm/syscalls/__fork.S
syscall_src += arch-arm/syscalls/waitid.S
syscall_src += arch-arm/syscalls/__clone.S
syscall_src += arch-arm/syscalls/execve.S
@@ -40,6 +40,8 @@ syscall_src += arch-arm/syscalls/capset.S
syscall_src += arch-arm/syscalls/acct.S
syscall_src += arch-arm/syscalls/read.S
syscall_src += arch-arm/syscalls/write.S
+syscall_src += arch-arm/syscalls/__pread64.S
+syscall_src += arch-arm/syscalls/__pwrite64.S
syscall_src += arch-arm/syscalls/__open.S
syscall_src += arch-arm/syscalls/__openat.S
syscall_src += arch-arm/syscalls/close.S
@@ -110,12 +112,13 @@ syscall_src += arch-arm/syscalls/clock_gettime.S
syscall_src += arch-arm/syscalls/clock_settime.S
syscall_src += arch-arm/syscalls/clock_getres.S
syscall_src += arch-arm/syscalls/clock_nanosleep.S
+syscall_src += arch-arm/syscalls/getitimer.S
syscall_src += arch-arm/syscalls/setitimer.S
-syscall_src += arch-arm/syscalls/timer_create.S
-syscall_src += arch-arm/syscalls/timer_settime.S
-syscall_src += arch-arm/syscalls/timer_gettime.S
-syscall_src += arch-arm/syscalls/timer_getoverrun.S
-syscall_src += arch-arm/syscalls/timer_delete.S
+syscall_src += arch-arm/syscalls/__timer_create.S
+syscall_src += arch-arm/syscalls/__timer_settime.S
+syscall_src += arch-arm/syscalls/__timer_gettime.S
+syscall_src += arch-arm/syscalls/__timer_getoverrun.S
+syscall_src += arch-arm/syscalls/__timer_delete.S
syscall_src += arch-arm/syscalls/utimes.S
syscall_src += arch-arm/syscalls/sigaction.S
syscall_src += arch-arm/syscalls/sigprocmask.S
diff --git a/libc/arch-arm/syscalls/fork.S b/libc/arch-arm/syscalls/__fork.S
index c9c18c4..fddd276 100644
--- a/libc/arch-arm/syscalls/fork.S
+++ b/libc/arch-arm/syscalls/__fork.S
@@ -2,12 +2,12 @@
#include <sys/linux-syscalls.h>
.text
- .type fork, #function
- .globl fork
+ .type __fork, #function
+ .globl __fork
.align 4
.fnstart
-fork:
+__fork:
.save {r4, r7}
stmfd sp!, {r4, r7}
ldr r7, =__NR_fork
diff --git a/libc/arch-arm/syscalls/__pread64.S b/libc/arch-arm/syscalls/__pread64.S
new file mode 100644
index 0000000..ea645e1
--- /dev/null
+++ b/libc/arch-arm/syscalls/__pread64.S
@@ -0,0 +1,21 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type __pread64, #function
+ .globl __pread64
+ .align 4
+ .fnstart
+
+__pread64:
+ mov ip, sp
+ .save {r4, r5, r6, r7}
+ stmfd sp!, {r4, r5, r6, r7}
+ ldmfd ip, {r4, r5, r6}
+ ldr r7, =__NR_pread64
+ swi #0
+ ldmfd sp!, {r4, r5, r6, r7}
+ movs r0, r0
+ bxpl lr
+ b __set_syscall_errno
+ .fnend
diff --git a/libc/arch-arm/syscalls/__pwrite64.S b/libc/arch-arm/syscalls/__pwrite64.S
new file mode 100644
index 0000000..d1263be
--- /dev/null
+++ b/libc/arch-arm/syscalls/__pwrite64.S
@@ -0,0 +1,21 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type __pwrite64, #function
+ .globl __pwrite64
+ .align 4
+ .fnstart
+
+__pwrite64:
+ mov ip, sp
+ .save {r4, r5, r6, r7}
+ stmfd sp!, {r4, r5, r6, r7}
+ ldmfd ip, {r4, r5, r6}
+ ldr r7, =__NR_pwrite64
+ swi #0
+ ldmfd sp!, {r4, r5, r6, r7}
+ movs r0, r0
+ bxpl lr
+ b __set_syscall_errno
+ .fnend
diff --git a/libc/arch-arm/syscalls/timer_create.S b/libc/arch-arm/syscalls/__timer_create.S
index a690777..5bc3966 100644
--- a/libc/arch-arm/syscalls/timer_create.S
+++ b/libc/arch-arm/syscalls/__timer_create.S
@@ -2,12 +2,12 @@
#include <sys/linux-syscalls.h>
.text
- .type timer_create, #function
- .globl timer_create
+ .type __timer_create, #function
+ .globl __timer_create
.align 4
.fnstart
-timer_create:
+__timer_create:
.save {r4, r7}
stmfd sp!, {r4, r7}
ldr r7, =__NR_timer_create
diff --git a/libc/arch-arm/syscalls/timer_delete.S b/libc/arch-arm/syscalls/__timer_delete.S
index b5d89f5..4ddee01 100644
--- a/libc/arch-arm/syscalls/timer_delete.S
+++ b/libc/arch-arm/syscalls/__timer_delete.S
@@ -2,12 +2,12 @@
#include <sys/linux-syscalls.h>
.text
- .type timer_delete, #function
- .globl timer_delete
+ .type __timer_delete, #function
+ .globl __timer_delete
.align 4
.fnstart
-timer_delete:
+__timer_delete:
.save {r4, r7}
stmfd sp!, {r4, r7}
ldr r7, =__NR_timer_delete
diff --git a/libc/arch-arm/syscalls/timer_getoverrun.S b/libc/arch-arm/syscalls/__timer_getoverrun.S
index 2dd4e22..fb0c87d 100644
--- a/libc/arch-arm/syscalls/timer_getoverrun.S
+++ b/libc/arch-arm/syscalls/__timer_getoverrun.S
@@ -2,12 +2,12 @@
#include <sys/linux-syscalls.h>
.text
- .type timer_getoverrun, #function
- .globl timer_getoverrun
+ .type __timer_getoverrun, #function
+ .globl __timer_getoverrun
.align 4
.fnstart
-timer_getoverrun:
+__timer_getoverrun:
.save {r4, r7}
stmfd sp!, {r4, r7}
ldr r7, =__NR_timer_getoverrun
diff --git a/libc/arch-arm/syscalls/timer_gettime.S b/libc/arch-arm/syscalls/__timer_gettime.S
index c4bb75c..9d6e446 100644
--- a/libc/arch-arm/syscalls/timer_gettime.S
+++ b/libc/arch-arm/syscalls/__timer_gettime.S
@@ -2,12 +2,12 @@
#include <sys/linux-syscalls.h>
.text
- .type timer_gettime, #function
- .globl timer_gettime
+ .type __timer_gettime, #function
+ .globl __timer_gettime
.align 4
.fnstart
-timer_gettime:
+__timer_gettime:
.save {r4, r7}
stmfd sp!, {r4, r7}
ldr r7, =__NR_timer_gettime
diff --git a/libc/arch-arm/syscalls/timer_settime.S b/libc/arch-arm/syscalls/__timer_settime.S
index d8a18ab..a7be132 100644
--- a/libc/arch-arm/syscalls/timer_settime.S
+++ b/libc/arch-arm/syscalls/__timer_settime.S
@@ -2,12 +2,12 @@
#include <sys/linux-syscalls.h>
.text
- .type timer_settime, #function
- .globl timer_settime
+ .type __timer_settime, #function
+ .globl __timer_settime
.align 4
.fnstart
-timer_settime:
+__timer_settime:
.save {r4, r7}
stmfd sp!, {r4, r7}
ldr r7, =__NR_timer_settime
diff --git a/libc/arch-arm/syscalls/getitimer.S b/libc/arch-arm/syscalls/getitimer.S
new file mode 100644
index 0000000..404c2fc
--- /dev/null
+++ b/libc/arch-arm/syscalls/getitimer.S
@@ -0,0 +1,19 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type getitimer, #function
+ .globl getitimer
+ .align 4
+ .fnstart
+
+getitimer:
+ .save {r4, r7}
+ stmfd sp!, {r4, r7}
+ ldr r7, =__NR_getitimer
+ swi #0
+ ldmfd sp!, {r4, r7}
+ movs r0, r0
+ bxpl lr
+ b __set_syscall_errno
+ .fnend
diff --git a/libc/arch-x86/bionic/__get_tls.c b/libc/arch-x86/bionic/__get_tls.c
index 68dda86..5ac6e44 100755
--- a/libc/arch-x86/bionic/__get_tls.c
+++ b/libc/arch-x86/bionic/__get_tls.c
@@ -26,12 +26,12 @@
* SUCH DAMAGE.
*/
/* see the implementation of __set_tls and pthread.c to understand this
- * code. Basically, the content of fs:[0] always is a pointer to the base
+ * code. Basically, the content of gs:[0] always is a pointer to the base
* address of the tls region
*/
void* __get_tls(void)
{
void* tls;
- asm ( " movl %%fs:0,%0" : "=r"(tls) );
+ asm ( " movl %%gs:0, %0" : "=r"(tls) );
return tls;
}
diff --git a/libc/arch-x86/bionic/__set_tls.c b/libc/arch-x86/bionic/__set_tls.c
index 8dff8d7..48b55f0 100755
--- a/libc/arch-x86/bionic/__set_tls.c
+++ b/libc/arch-x86/bionic/__set_tls.c
@@ -27,6 +27,7 @@
*/
#include <pthread.h>
+
struct user_desc {
unsigned int entry_number;
unsigned long base_addr;
@@ -40,6 +41,8 @@ struct user_desc {
unsigned int empty:25;
};
+extern int __set_thread_area(struct user_desc *u_info);
+
/* the following can't be const, since the first call will
* update the 'entry_number' field
*/
@@ -57,7 +60,11 @@ static struct user_desc _tls_desc =
0
};
-/* we implement thread local storage through the fs: segment descriptor
+struct _thread_area_head {
+ void *self;
+};
+
+/* we implement thread local storage through the gs: segment descriptor
* we create a segment descriptor for the tls
*/
int __set_tls(void *ptr)
@@ -66,6 +73,9 @@ int __set_tls(void *ptr)
_tls_desc.base_addr = (unsigned long)ptr;
+ /* We also need to write the location of the tls to ptr[0] */
+ ((struct _thread_area_head *)ptr)->self = ptr;
+
rc = __set_thread_area( &_tls_desc );
if (rc != 0)
{
@@ -76,7 +86,7 @@ int __set_tls(void *ptr)
/* this weird computation comes from GLibc */
segment = _tls_desc.entry_number*8 + 3;
asm __volatile__ (
- " movw %w0, %%fs" :: "r"(segment)
+ " movw %w0, %%gs" :: "q"(segment)
);
return 0;
}
diff --git a/libc/arch-x86/bionic/_exit_with_stack_teardown.S b/libc/arch-x86/bionic/_exit_with_stack_teardown.S
new file mode 100644
index 0000000..83a504d
--- /dev/null
+++ b/libc/arch-x86/bionic/_exit_with_stack_teardown.S
@@ -0,0 +1,34 @@
+#include <sys/linux-syscalls.h>
+
+.text
+.type _exit_with_stack_teardown, @function
+.globl _exit_with_stack_teardown
+.align 4
+
+/*
+ * void _exit_with_stack_teardown(void *stackBase, int stackSize, int *retCode)
+ */
+
+_exit_with_stack_teardown:
+ /* we can trash %ebx here since this call should never return. */
+ /* We can also take advantage of the fact that the linux syscall trap
+ * handler saves all the registers, so we don't need a stack to keep
+ * the retCode argument for exit while doing the munmap */
+
+ /* TODO(dmtriyz): No one expects this code to return, so even if
+ * munmap fails, we have to exit. This should probably be fixed, but
+ * since ARM side does the same thing, leave it as is.
+ */
+ mov 4(%esp), %ebx /* stackBase */
+ mov 8(%esp), %ecx /* stackSize */
+ mov 12(%esp), %edx /* retCode, not used for munmap */
+ mov $__NR_munmap, %eax
+ int $0x80
+ mov %edx, %ebx /* retrieve the retCode */
+ movl $__NR_exit, %eax
+ int $0x80
+ /* exit does not return */
+ /* can't have a ret here since we no longer have a usable stack. Seems
+ * that presently, 'hlt' will cause the program to segfault.. but this
+ * should never happen :) */
+ hlt
diff --git a/libc/arch-x86/bionic/_setjmp.S b/libc/arch-x86/bionic/_setjmp.S
new file mode 100644
index 0000000..ac62635
--- /dev/null
+++ b/libc/arch-x86/bionic/_setjmp.S
@@ -0,0 +1,71 @@
+/* $OpenBSD: _setjmp.S,v 1.5 2005/08/07 11:30:38 espie Exp $ */
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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.
+ */
+
+#include <machine/asm.h>
+
+/*
+ * C library -- _setjmp, _longjmp
+ *
+ * _longjmp(a,v)
+ * will generate a "return(v)" from the last call to
+ * _setjmp(a)
+ * by restoring registers from the stack.
+ * The previous signal state is NOT restored.
+ */
+
+ENTRY(_setjmp)
+ movl 4(%esp),%eax
+ movl 0(%esp),%edx
+ movl %edx, 0(%eax) /* rta */
+ movl %ebx, 4(%eax)
+ movl %esp, 8(%eax)
+ movl %ebp,12(%eax)
+ movl %esi,16(%eax)
+ movl %edi,20(%eax)
+ xorl %eax,%eax
+ ret
+
+ENTRY(_longjmp)
+ movl 4(%esp),%edx
+ movl 8(%esp),%eax
+ movl 0(%edx),%ecx
+ movl 4(%edx),%ebx
+ movl 8(%edx),%esp
+ movl 12(%edx),%ebp
+ movl 16(%edx),%esi
+ movl 20(%edx),%edi
+ testl %eax,%eax
+ jnz 1f
+ incl %eax
+1: movl %ecx,0(%esp)
+ ret
diff --git a/libc/arch-x86/bionic/atomics_x86.S b/libc/arch-x86/bionic/atomics_x86.S
new file mode 100644
index 0000000..2370f23
--- /dev/null
+++ b/libc/arch-x86/bionic/atomics_x86.S
@@ -0,0 +1,140 @@
+#include <sys/linux-syscalls.h>
+
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+
+
+/*
+ * int __futex_wait(volatile void *ftx, int val, const struct timespec *timeout)
+ */
+.text
+.globl __futex_wait
+.type __futex_wait, @function
+.align 4
+__futex_wait:
+ pushl %ebx
+ pushl %esi
+ mov 12(%esp), %ebx /* ftx */
+ movl $FUTEX_WAIT, %ecx
+ mov 16(%esp), %edx /* val */
+ mov 20(%esp), %esi /* timeout */
+ movl $__NR_futex, %eax
+ int $0x80
+ popl %esi
+ popl %ebx
+ ret
+
+
+/* int __futex_wake(volatile void *ftx, int count) */
+
+.text
+.globl __futex_wake
+.type __futex_wake, @function
+.align 4
+__futex_wake:
+ pushl %ebx
+ mov 8(%esp), %ebx /* ftx */
+ movl $FUTEX_WAKE, %ecx
+ mov 12(%esp), %edx /* count */
+ movl $__NR_futex, %eax
+ int $0x80
+ popl %ebx
+ ret
+
+
+/* int __atomic_cmpxchg(int old, int new, volatile int* addr) */
+
+.text
+.globl __atomic_cmpxchg
+.type __atomic_cmpxchg, @function
+.align 4
+__atomic_cmpxchg:
+ mov 4(%esp), %eax /* old */
+ mov 8(%esp), %ecx /* new */
+ mov 12(%esp), %edx /* addr */
+ lock cmpxchg %ecx, (%edx)
+ jnz 1f
+ xor %eax, %eax
+ jmp 2f
+1:
+ movl $1, %eax
+2:
+ ret /* 0 == success, 1 == failure */
+
+
+/* int __atomic_swap(int new, volatile int* addr) */
+
+.text
+.globl __atomic_swap
+.type __atomic_swap, @function
+.align 4
+__atomic_swap:
+ mov 4(%esp), %ecx /* new */
+ mov 8(%esp), %edx /* addr */
+ lock xchg %ecx, (%edx)
+ mov %ecx, %eax
+ ret
+
+
+/*
+ * int __atomic_dec(volatile int* addr)
+ *
+ * My x86 asm is really rusty.. this is probably suboptimal
+ */
+
+.text
+.globl __atomic_dec
+.type __atomic_dec, @function
+.align 4
+__atomic_dec:
+ pushl %ebx
+ pushl %esi
+ movl 12(%esp), %ebx /* addr */
+
+1:
+ movl (%ebx), %esi /* old = *addr */
+ movl %esi, %edx
+ subl $1, %edx /* new = old - 1 */
+
+ pushl %ebx
+ pushl %edx
+ pushl %esi
+ call __atomic_cmpxchg
+ addl $12, %esp
+ test %eax, %eax
+ jnz 1b
+
+ movl %esi, %eax /* return old */
+ popl %esi
+ popl %ebx
+ ret
+
+
+.text
+/* int __atomic_inc(volatile int* addr) */
+.globl __atomic_inc
+.type __atomic_inc, @function
+.align 4
+__atomic_inc:
+ pushl %ebx
+ pushl %esi
+ movl 12(%esp), %ebx /* addr */
+
+1:
+ movl (%ebx), %esi /* old = *addr */
+ movl %esi, %edx
+ addl $1, %edx /* new = old + 1 */
+
+ pushl %ebx
+ pushl %edx
+ pushl %esi
+ call __atomic_cmpxchg
+ addl $12, %esp
+ test %eax, %eax
+ jnz 1b
+
+ movl %esi, %eax /* return old */
+ popl %esi
+ popl %ebx
+ ret
+
diff --git a/libc/arch-x86/bionic/clone.S b/libc/arch-x86/bionic/clone.S
new file mode 100644
index 0000000..361808d
--- /dev/null
+++ b/libc/arch-x86/bionic/clone.S
@@ -0,0 +1,50 @@
+#include <sys/linux-syscalls.h>
+
+.text
+
+/*
+ * int __pthread_clone(int (*fn)(void*), void *tls, int flags,
+ * void *arg);
+ */
+.globl __pthread_clone
+.type __pthread_clone, @function
+.align 4
+__pthread_clone:
+ pushl %ebx
+ pushl %ecx
+ movl 16(%esp), %ecx
+ movl 20(%esp), %ebx
+
+ # insert arguments onto the child stack
+ movl 12(%esp), %eax
+ movl %eax, -12(%ecx)
+ movl 24(%esp), %eax
+ movl %eax, -8(%ecx)
+ lea (%ecx), %eax
+ movl %eax, -4(%ecx)
+
+ movl $__NR_clone, %eax
+ int $0x80
+ test %eax, %eax
+ jns 1f
+
+ # an error occured, set errno and return -1
+ negl %eax
+ call __set_errno
+ orl $-1, %eax
+ jmp 2f
+
+1:
+ jnz 2f
+
+ # we're in the child thread now, call __thread_entry
+ # with the appropriate arguments on the child stack
+ # we already placed most of them
+ subl $16, %esp
+ jmp __thread_entry
+ hlt
+
+2:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/bionic/crtbegin_dynamic.S b/libc/arch-x86/bionic/crtbegin_dynamic.S
new file mode 100644
index 0000000..3b47b18
--- /dev/null
+++ b/libc/arch-x86/bionic/crtbegin_dynamic.S
@@ -0,0 +1,96 @@
+# bionic/arch-x86/bionic/crtbegin_dynamic.S
+#
+# Copyright 2006, The Android Open Source Project
+#
+# Redistribution and use in source and binary forms, with or without
+# 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 Google 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 Google Inc. ``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 Google Inc. 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.
+
+ .text
+ .align 4
+ .type _start, @function
+ .globl _start
+
+# this is the small startup code that is first run when
+# any executable that is statically-linked with Bionic
+# runs.
+#
+# it's purpose is to call __libc_init with appropriate
+# arguments, which are:
+#
+# - the address of the raw data block setup by the Linux
+# kernel ELF loader
+#
+# - address of an "onexit" function, not used on any
+# platform supported by Bionic
+#
+# - address of the "main" function of the program. We
+# can't hard-code it in the adr pseudo instruction
+# so we use a tiny trampoline that will get relocated
+# by the dynamic linker before this code runs
+#
+# - address of the constructor list
+#
+_start:
+ mov %esp, %eax
+ mov $1f, %edx
+ pushl %edx
+ mov $0f, %edx
+ pushl %edx
+ mov $0, %edx
+ pushl %edx
+ pushl %eax
+ call __libc_init
+
+0:
+ jmp main
+
+1: .long __PREINIT_ARRAY__
+ .long __INIT_ARRAY__
+ .long __FINI_ARRAY__
+ .long __CTOR_LIST__
+
+# the .ctors section contains a list of pointers to "constructor"
+# functions that need to be called in order during C library initialization,
+# just before the program is being run. This is a C++ requirement
+#
+# the last entry shall be 0, and is defined in crtend.S
+#
+ .section .preinit_array, "aw"
+ .globl __PREINIT_ARRAY__
+__PREINIT_ARRAY__:
+ .long -1
+
+ .section .init_array, "aw"
+ .globl __INIT_ARRAY__
+__INIT_ARRAY__:
+ .long -1
+
+ .section .fini_array, "aw"
+ .globl __FINI_ARRAY__
+__FINI_ARRAY__:
+ .long -1
+
+ .section .ctors, "aw"
+ .globl __CTOR_LIST__
+__CTOR_LIST__:
+ .long -1
+
diff --git a/libc/arch-x86/bionic/crtbegin_so.S b/libc/arch-x86/bionic/crtbegin_so.S
new file mode 100644
index 0000000..d49e9df
--- /dev/null
+++ b/libc/arch-x86/bionic/crtbegin_so.S
@@ -0,0 +1,29 @@
+/* we put the _init() function here in case the user files for the shared
+ * libs want to drop things into .init section.
+ * We then will call our ctors from crtend_so.o */
+.section .init
+.align 4
+.type _init, @function
+.globl _init
+_init:
+
+.section .init_array, "aw"
+.align 4
+.type __INIT_ARRAY__, @object
+.globl __INIT_ARRAY__
+__INIT_ARRAY__:
+ .long -1
+
+.section .fini_array, "aw"
+.align 4
+.type __FINI_ARRAY__, @object
+.globl __FINI_ARRAY__
+__FINI_ARRAY__:
+ .long -1
+
+.section .ctors, "aw"
+.align 4
+.type __CTOR_LIST__, @object
+.globl __CTOR_LIST__
+__CTOR_LIST__:
+ .long -1
diff --git a/libc/arch-x86/bionic/crtbegin_static.S b/libc/arch-x86/bionic/crtbegin_static.S
new file mode 100644
index 0000000..eb4acee
--- /dev/null
+++ b/libc/arch-x86/bionic/crtbegin_static.S
@@ -0,0 +1,95 @@
+# bionic/arch-x86/bionic/crtbegin_static.S
+#
+# Copyright 2006, The Android Open Source Project
+#
+# Redistribution and use in source and binary forms, with or without
+# 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 Google 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 Google Inc. ``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 Google Inc. 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.
+
+ .text
+ .align 4
+ .type _start, @function
+ .globl _start
+
+# this is the small startup code that is first run when
+# any executable that is statically-linked with Bionic
+# runs.
+#
+# it's purpose is to call __libc_init with appropriate
+# arguments, which are:
+#
+# - the address of the raw data block setup by the Linux
+# kernel ELF loader
+#
+# - address of an "onexit" function, not used on any
+# platform supported by Bionic
+#
+# - address of the "main" function of the program. We
+# can't hard-code it in the adr pseudo instruction
+# so we use a tiny trampoline that will get relocated
+# by the dynamic linker before this code runs
+#
+# - address of the constructor list
+#
+_start:
+ mov %esp, %eax
+ mov $1f, %edx
+ pushl %edx
+ mov $0f, %edx
+ pushl %edx
+ mov $0, %edx
+ pushl %edx
+ pushl %eax
+ call __libc_init
+
+0: jmp main
+
+1: .long __PREINIT_ARRAY__
+ .long __INIT_ARRAY__
+ .long __FINI_ARRAY__
+ .long __CTOR_LIST__
+
+# the .ctors section contains a list of pointers to "constructor"
+# functions that need to be called in order during C library initialization,
+# just before the program is being run. This is a C++ requirement
+#
+# the last entry shall be 0, and is defined in crtend.S
+#
+ .section .preinit_array, "aw"
+ .globl __PREINIT_ARRAY__
+__PREINIT_ARRAY__:
+ .long -1
+
+ .section .init_array, "aw"
+ .globl __INIT_ARRAY__
+__INIT_ARRAY__:
+ .long -1
+
+ .section .fini_array, "aw"
+ .globl __FINI_ARRAY__
+__FINI_ARRAY__:
+ .long -1
+
+ .section .ctors, "aw"
+ .globl __CTOR_LIST__
+__CTOR_LIST__:
+ .long -1
+
diff --git a/libc/arch-x86/bionic/crtend.S b/libc/arch-x86/bionic/crtend.S
new file mode 100644
index 0000000..7f5fb66
--- /dev/null
+++ b/libc/arch-x86/bionic/crtend.S
@@ -0,0 +1,13 @@
+
+ .section .preinit_array, "aw"
+ .long 0
+
+ .section .init_array, "aw"
+ .long 0
+
+ .section .fini_array, "aw"
+ .long 0
+
+ .section .ctors, "aw"
+ .long 0
+
diff --git a/libc/arch-x86/bionic/crtend_so.S b/libc/arch-x86/bionic/crtend_so.S
new file mode 100644
index 0000000..7fb2280
--- /dev/null
+++ b/libc/arch-x86/bionic/crtend_so.S
@@ -0,0 +1,47 @@
+.text
+.align 4
+.type __bionic_call_ctors, @function
+
+/*
+ * The CTORS_LIST is marked by -1 (start) and 0 (end).
+ * We mark the end of the .ctors section with the __CTOR_END__ section so
+ * that we can just iterate backwards from it until we hit -1 and execute
+ * all the function pointers. This seems to be the way to do it for SVR4
+ * derived systems.
+ */
+__bionic_call_ctors:
+ pushl %esi
+ mov $__CTOR_END__, %esi
+
+0:
+ /* now grab the next function pointer and check if its -1. If not,
+ * call it, otherwise we're done. We use %esi since it's callee saved.
+ */
+ subl $4, %esi
+ mov (%esi), %eax
+ cmp $0xffffffff, %eax
+ je 1f
+ call *%eax
+ jmp 0b
+
+1:
+ /* we're done */
+ popl %esi
+ ret
+
+.section .init
+.align 4
+ call __bionic_call_ctors
+ ret
+
+.section .ctors, "aw", @progbits
+.align 4
+.type __CTOR_END__, @object
+__CTOR_END__:
+ .long 0
+
+.section .init_array, "aw"
+ .long 0
+
+.section .fini_array, "aw"
+ .long 0
diff --git a/libc/arch-x86/bionic/dl_iterate_phdr_static.c b/libc/arch-x86/bionic/dl_iterate_phdr_static.c
new file mode 100644
index 0000000..fd12106
--- /dev/null
+++ b/libc/arch-x86/bionic/dl_iterate_phdr_static.c
@@ -0,0 +1,74 @@
+/* bionic/arch-x86/bionic/dl_iterate_phdr_static.c
+**
+** Copyright 2006, The Android Open Source Project
+**
+** Redistribution and use in source and binary forms, with or without
+** 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 Google 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 Google Inc. ``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 Google Inc. 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.
+*/
+
+#include <sys/types.h>
+#include <linux/elf.h>
+
+/* TODO: Move this into a header that linker.h can also pull it in.
+ * Silly to have same struct in 2 places. This is temporary. */
+struct dl_phdr_info
+{
+ Elf32_Addr dlpi_addr;
+ const char *dlpi_name;
+ const Elf32_Phdr *dlpi_phdr;
+ Elf32_Half dlpi_phnum;
+};
+
+/* Dynamic binaries get this from the dynamic linker (system/linker), which
+ * we don't pull in for static bins. We also don't have a list of so's to
+ * iterate over, since there's really only a single monolithic blob of
+ * code/data.
+ *
+ * All we need to do is to find where the executable is in memory, and grab the
+ * phdr and phnum from there.
+ */
+
+/* ld provides this to us in the default link script */
+extern void *__executable_start;
+
+int
+dl_iterate_phdr(int (*cb)(struct dl_phdr_info *info, size_t size, void *data),
+ void *data)
+{
+ struct dl_phdr_info dl_info;
+ Elf32_Ehdr *ehdr = (Elf32_Ehdr *) &__executable_start;
+ Elf32_Phdr *phdr = (Elf32_Phdr *)((unsigned long)ehdr + ehdr->e_phoff);
+
+ /* TODO: again, copied from linker.c. Find a better home for this
+ * later. */
+ if (ehdr->e_ident[EI_MAG0] != ELFMAG0) return -1;
+ if (ehdr->e_ident[EI_MAG1] != ELFMAG1) return -1;
+ if (ehdr->e_ident[EI_MAG2] != ELFMAG2) return -1;
+ if (ehdr->e_ident[EI_MAG3] != ELFMAG3) return -1;
+
+ dl_info.dlpi_addr = 0;
+ dl_info.dlpi_name = NULL;
+ dl_info.dlpi_phdr = phdr;
+ dl_info.dlpi_phnum = ehdr->e_phnum;
+ return cb(&dl_info, sizeof (struct dl_phdr_info), data);
+}
+
diff --git a/libc/arch-x86/bionic/setjmp.S b/libc/arch-x86/bionic/setjmp.S
new file mode 100644
index 0000000..bcb5f9d
--- /dev/null
+++ b/libc/arch-x86/bionic/setjmp.S
@@ -0,0 +1,93 @@
+/* $OpenBSD: setjmp.S,v 1.8 2005/08/07 11:30:38 espie Exp $ */
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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.
+ */
+
+#include <machine/asm.h>
+
+/*
+ * C library -- setjmp, longjmp
+ *
+ * longjmp(a,v)
+ * will generate a "return(v)" from the last call to
+ * setjmp(a)
+ * by restoring registers from the stack.
+ * The previous signal state is restored.
+ */
+
+ENTRY(setjmp)
+ PIC_PROLOGUE
+ pushl $0
+#ifdef PIC
+ call PIC_PLT(_C_LABEL(sigblock))
+#else
+ call _C_LABEL(sigblock)
+#endif
+ addl $4,%esp
+ PIC_EPILOGUE
+
+ movl 4(%esp),%ecx
+ movl 0(%esp),%edx
+ movl %edx, 0(%ecx)
+ movl %ebx, 4(%ecx)
+ movl %esp, 8(%ecx)
+ movl %ebp,12(%ecx)
+ movl %esi,16(%ecx)
+ movl %edi,20(%ecx)
+ movl %eax,24(%ecx)
+ xorl %eax,%eax
+ ret
+
+ENTRY(longjmp)
+ movl 4(%esp),%edx
+ PIC_PROLOGUE
+ pushl 24(%edx)
+#ifdef PIC
+ call PIC_PLT(_C_LABEL(sigsetmask))
+#else
+ call _C_LABEL(sigsetmask)
+#endif
+ addl $4,%esp
+ PIC_EPILOGUE
+
+ movl 4(%esp),%edx
+ movl 8(%esp),%eax
+ movl 0(%edx),%ecx
+ movl 4(%edx),%ebx
+ movl 8(%edx),%esp
+ movl 12(%edx),%ebp
+ movl 16(%edx),%esi
+ movl 20(%edx),%edi
+ testl %eax,%eax
+ jnz 1f
+ incl %eax
+1: movl %ecx,0(%esp)
+ ret
diff --git a/libc/arch-x86/bionic/vfork.S b/libc/arch-x86/bionic/vfork.S
new file mode 100644
index 0000000..53910ab
--- /dev/null
+++ b/libc/arch-x86/bionic/vfork.S
@@ -0,0 +1,30 @@
+#include <sys/linux-syscalls.h>
+
+#ifndef __NR_vfork
+#define __NR_vfork 190
+#endif
+
+
+ .text
+ .type vfork, @function
+ .globl vfork
+ .align 4
+
+/* Get rid of the stack modifications (popl/ret) after vfork() success.
+ * vfork is VERY sneaky. One has to be very careful about what can be done
+ * between a successful vfork and a a subsequent execve()
+ */
+
+vfork:
+ /* grab the return address */
+ popl %ecx
+ movl $__NR_vfork, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ orl $-1, %eax
+1:
+ jmp *%ecx
diff --git a/libc/arch-x86/include/machine/asm.h b/libc/arch-x86/include/machine/asm.h
index f2da575..7a23060 100644
--- a/libc/arch-x86/include/machine/asm.h
+++ b/libc/arch-x86/include/machine/asm.h
@@ -38,6 +38,17 @@
#ifndef _I386_ASM_H_
#define _I386_ASM_H_
+/* This is borrowed from FreeBSD /src/sys/i386/include/asmacros.h v1.27 */
+/*
+ * CNAME and HIDENAME manage the relationship between symbol names in C
+ * and the equivalent assembly language names. CNAME is given a name as
+ * it would be used in a C program. It expands to the equivalent assembly
+ * language name. HIDENAME is given an assembly-language name, and expands
+ * to a possibly-modified form that will be invisible to C programs.
+ */
+#define CNAME(csym) csym
+#define HIDENAME(asmsym) .asmsym
+
#ifdef PIC
#define PIC_PROLOGUE \
pushl %ebx; \
@@ -108,5 +119,6 @@
#define ASMSTR .asciz
#define RCSID(x) .text; .asciz x
+#define __FBSDID(x) RCSID(x)
#endif /* !_I386_ASM_H_ */
diff --git a/libc/arch-x86/include/machine/kernel.h b/libc/arch-x86/include/machine/kernel.h
new file mode 100644
index 0000000..19d1577
--- /dev/null
+++ b/libc/arch-x86/include/machine/kernel.h
@@ -0,0 +1,41 @@
+/* bionic/arch-arm/include/machine/kernel.h
+**
+** Copyright 2006-2008, The Android Open Source Project
+**
+** Redistribution and use in source and binary forms, with or without
+** 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 Google 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 Google Inc. ``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 Google Inc. 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.
+*/
+#ifndef _ARCH_X86_KERNEL_H
+#define _ARCH_X86_KERNEL_H
+
+/* this file contains kernel-specific definitions that were optimized out of
+ our processed kernel headers, but still useful nonetheless... */
+
+typedef unsigned long __kernel_blkcnt_t;
+typedef unsigned long __kernel_blksize_t;
+
+/* these aren't really defined by the kernel headers though... */
+typedef unsigned long __kernel_fsblkcnt_t;
+typedef unsigned long __kernel_fsfilcnt_t;
+typedef unsigned int __kernel_id_t;
+
+#endif /* _ARCH_X86_KERNEL_H */
diff --git a/libc/arch-x86/syscalls.mk b/libc/arch-x86/syscalls.mk
new file mode 100644
index 0000000..86d2308
--- /dev/null
+++ b/libc/arch-x86/syscalls.mk
@@ -0,0 +1,171 @@
+# auto-generated by gensyscalls.py, do not touch
+syscall_src :=
+syscall_src += arch-x86/syscalls/_exit.S
+syscall_src += arch-x86/syscalls/_exit_thread.S
+syscall_src += arch-x86/syscalls/__fork.S
+syscall_src += arch-x86/syscalls/_waitpid.S
+syscall_src += arch-x86/syscalls/waitid.S
+syscall_src += arch-x86/syscalls/__clone.S
+syscall_src += arch-x86/syscalls/execve.S
+syscall_src += arch-x86/syscalls/setuid.S
+syscall_src += arch-x86/syscalls/getuid.S
+syscall_src += arch-x86/syscalls/getgid.S
+syscall_src += arch-x86/syscalls/geteuid.S
+syscall_src += arch-x86/syscalls/getegid.S
+syscall_src += arch-x86/syscalls/getresuid.S
+syscall_src += arch-x86/syscalls/getresgid.S
+syscall_src += arch-x86/syscalls/gettid.S
+syscall_src += arch-x86/syscalls/getgroups.S
+syscall_src += arch-x86/syscalls/getpgid.S
+syscall_src += arch-x86/syscalls/getppid.S
+syscall_src += arch-x86/syscalls/setsid.S
+syscall_src += arch-x86/syscalls/setgid.S
+syscall_src += arch-x86/syscalls/setreuid.S
+syscall_src += arch-x86/syscalls/setresuid.S
+syscall_src += arch-x86/syscalls/setresgid.S
+syscall_src += arch-x86/syscalls/__brk.S
+syscall_src += arch-x86/syscalls/kill.S
+syscall_src += arch-x86/syscalls/tkill.S
+syscall_src += arch-x86/syscalls/__ptrace.S
+syscall_src += arch-x86/syscalls/__set_thread_area.S
+syscall_src += arch-x86/syscalls/__getpriority.S
+syscall_src += arch-x86/syscalls/setpriority.S
+syscall_src += arch-x86/syscalls/setrlimit.S
+syscall_src += arch-x86/syscalls/getrlimit.S
+syscall_src += arch-x86/syscalls/getrusage.S
+syscall_src += arch-x86/syscalls/setgroups.S
+syscall_src += arch-x86/syscalls/setpgid.S
+syscall_src += arch-x86/syscalls/setregid.S
+syscall_src += arch-x86/syscalls/chroot.S
+syscall_src += arch-x86/syscalls/prctl.S
+syscall_src += arch-x86/syscalls/capget.S
+syscall_src += arch-x86/syscalls/capset.S
+syscall_src += arch-x86/syscalls/acct.S
+syscall_src += arch-x86/syscalls/read.S
+syscall_src += arch-x86/syscalls/write.S
+syscall_src += arch-x86/syscalls/__pread64.S
+syscall_src += arch-x86/syscalls/__pwrite64.S
+syscall_src += arch-x86/syscalls/__open.S
+syscall_src += arch-x86/syscalls/__openat.S
+syscall_src += arch-x86/syscalls/close.S
+syscall_src += arch-x86/syscalls/lseek.S
+syscall_src += arch-x86/syscalls/__llseek.S
+syscall_src += arch-x86/syscalls/getpid.S
+syscall_src += arch-x86/syscalls/__mmap2.S
+syscall_src += arch-x86/syscalls/munmap.S
+syscall_src += arch-x86/syscalls/mremap.S
+syscall_src += arch-x86/syscalls/msync.S
+syscall_src += arch-x86/syscalls/mprotect.S
+syscall_src += arch-x86/syscalls/madvise.S
+syscall_src += arch-x86/syscalls/mlock.S
+syscall_src += arch-x86/syscalls/munlock.S
+syscall_src += arch-x86/syscalls/mincore.S
+syscall_src += arch-x86/syscalls/__ioctl.S
+syscall_src += arch-x86/syscalls/readv.S
+syscall_src += arch-x86/syscalls/writev.S
+syscall_src += arch-x86/syscalls/__fcntl.S
+syscall_src += arch-x86/syscalls/flock.S
+syscall_src += arch-x86/syscalls/fchmod.S
+syscall_src += arch-x86/syscalls/dup.S
+syscall_src += arch-x86/syscalls/pipe.S
+syscall_src += arch-x86/syscalls/dup2.S
+syscall_src += arch-x86/syscalls/select.S
+syscall_src += arch-x86/syscalls/ftruncate.S
+syscall_src += arch-x86/syscalls/getdents.S
+syscall_src += arch-x86/syscalls/fsync.S
+syscall_src += arch-x86/syscalls/fchown.S
+syscall_src += arch-x86/syscalls/sync.S
+syscall_src += arch-x86/syscalls/__fcntl64.S
+syscall_src += arch-x86/syscalls/fstatfs.S
+syscall_src += arch-x86/syscalls/sendfile.S
+syscall_src += arch-x86/syscalls/fstatat.S
+syscall_src += arch-x86/syscalls/mkdirat.S
+syscall_src += arch-x86/syscalls/fchownat.S
+syscall_src += arch-x86/syscalls/fchmodat.S
+syscall_src += arch-x86/syscalls/renameat.S
+syscall_src += arch-x86/syscalls/link.S
+syscall_src += arch-x86/syscalls/unlink.S
+syscall_src += arch-x86/syscalls/unlinkat.S
+syscall_src += arch-x86/syscalls/chdir.S
+syscall_src += arch-x86/syscalls/mknod.S
+syscall_src += arch-x86/syscalls/chmod.S
+syscall_src += arch-x86/syscalls/chown.S
+syscall_src += arch-x86/syscalls/lchown.S
+syscall_src += arch-x86/syscalls/mount.S
+syscall_src += arch-x86/syscalls/umount2.S
+syscall_src += arch-x86/syscalls/fstat.S
+syscall_src += arch-x86/syscalls/stat.S
+syscall_src += arch-x86/syscalls/lstat.S
+syscall_src += arch-x86/syscalls/mkdir.S
+syscall_src += arch-x86/syscalls/readlink.S
+syscall_src += arch-x86/syscalls/rmdir.S
+syscall_src += arch-x86/syscalls/rename.S
+syscall_src += arch-x86/syscalls/__getcwd.S
+syscall_src += arch-x86/syscalls/access.S
+syscall_src += arch-x86/syscalls/symlink.S
+syscall_src += arch-x86/syscalls/fchdir.S
+syscall_src += arch-x86/syscalls/truncate.S
+syscall_src += arch-x86/syscalls/__statfs64.S
+syscall_src += arch-x86/syscalls/pause.S
+syscall_src += arch-x86/syscalls/gettimeofday.S
+syscall_src += arch-x86/syscalls/settimeofday.S
+syscall_src += arch-x86/syscalls/times.S
+syscall_src += arch-x86/syscalls/nanosleep.S
+syscall_src += arch-x86/syscalls/clock_gettime.S
+syscall_src += arch-x86/syscalls/clock_settime.S
+syscall_src += arch-x86/syscalls/clock_getres.S
+syscall_src += arch-x86/syscalls/clock_nanosleep.S
+syscall_src += arch-x86/syscalls/getitimer.S
+syscall_src += arch-x86/syscalls/setitimer.S
+syscall_src += arch-x86/syscalls/__timer_create.S
+syscall_src += arch-x86/syscalls/__timer_settime.S
+syscall_src += arch-x86/syscalls/__timer_gettime.S
+syscall_src += arch-x86/syscalls/__timer_getoverrun.S
+syscall_src += arch-x86/syscalls/__timer_delete.S
+syscall_src += arch-x86/syscalls/utimes.S
+syscall_src += arch-x86/syscalls/sigaction.S
+syscall_src += arch-x86/syscalls/sigprocmask.S
+syscall_src += arch-x86/syscalls/__sigsuspend.S
+syscall_src += arch-x86/syscalls/__rt_sigaction.S
+syscall_src += arch-x86/syscalls/__rt_sigprocmask.S
+syscall_src += arch-x86/syscalls/__rt_sigtimedwait.S
+syscall_src += arch-x86/syscalls/sigpending.S
+syscall_src += arch-x86/syscalls/socket.S
+syscall_src += arch-x86/syscalls/bind.S
+syscall_src += arch-x86/syscalls/connect.S
+syscall_src += arch-x86/syscalls/listen.S
+syscall_src += arch-x86/syscalls/accept.S
+syscall_src += arch-x86/syscalls/getsockname.S
+syscall_src += arch-x86/syscalls/getpeername.S
+syscall_src += arch-x86/syscalls/socketpair.S
+syscall_src += arch-x86/syscalls/sendto.S
+syscall_src += arch-x86/syscalls/recvfrom.S
+syscall_src += arch-x86/syscalls/shutdown.S
+syscall_src += arch-x86/syscalls/setsockopt.S
+syscall_src += arch-x86/syscalls/getsockopt.S
+syscall_src += arch-x86/syscalls/sendmsg.S
+syscall_src += arch-x86/syscalls/recvmsg.S
+syscall_src += arch-x86/syscalls/sched_setscheduler.S
+syscall_src += arch-x86/syscalls/sched_getscheduler.S
+syscall_src += arch-x86/syscalls/sched_yield.S
+syscall_src += arch-x86/syscalls/sched_setparam.S
+syscall_src += arch-x86/syscalls/sched_getparam.S
+syscall_src += arch-x86/syscalls/sched_get_priority_max.S
+syscall_src += arch-x86/syscalls/sched_get_priority_min.S
+syscall_src += arch-x86/syscalls/sched_rr_get_interval.S
+syscall_src += arch-x86/syscalls/uname.S
+syscall_src += arch-x86/syscalls/__wait4.S
+syscall_src += arch-x86/syscalls/umask.S
+syscall_src += arch-x86/syscalls/__reboot.S
+syscall_src += arch-x86/syscalls/__syslog.S
+syscall_src += arch-x86/syscalls/init_module.S
+syscall_src += arch-x86/syscalls/delete_module.S
+syscall_src += arch-x86/syscalls/klogctl.S
+syscall_src += arch-x86/syscalls/futex.S
+syscall_src += arch-x86/syscalls/epoll_create.S
+syscall_src += arch-x86/syscalls/epoll_ctl.S
+syscall_src += arch-x86/syscalls/epoll_wait.S
+syscall_src += arch-x86/syscalls/inotify_init.S
+syscall_src += arch-x86/syscalls/inotify_add_watch.S
+syscall_src += arch-x86/syscalls/inotify_rm_watch.S
+syscall_src += arch-x86/syscalls/poll.S
diff --git a/libc/arch-x86/syscalls/fork.S b/libc/arch-x86/syscalls/__fork.S
index fbc1af3..4b5d1c6 100644
--- a/libc/arch-x86/syscalls/fork.S
+++ b/libc/arch-x86/syscalls/__fork.S
@@ -2,11 +2,11 @@
#include <sys/linux-syscalls.h>
.text
- .type fork, @function
- .globl fork
+ .type __fork, @function
+ .globl __fork
.align 4
-fork:
+__fork:
pushl %ebx
mov 8(%esp), %ebx
movl $__NR_fork, %eax
diff --git a/libc/arch-x86/syscalls/__pread64.S b/libc/arch-x86/syscalls/__pread64.S
new file mode 100644
index 0000000..3114673
--- /dev/null
+++ b/libc/arch-x86/syscalls/__pread64.S
@@ -0,0 +1,35 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type __pread64, @function
+ .globl __pread64
+ .align 4
+
+__pread64:
+ pushl %ebx
+ pushl %ecx
+ pushl %edx
+ pushl %esi
+ pushl %edi
+ mov 24(%esp), %ebx
+ mov 28(%esp), %ecx
+ mov 32(%esp), %edx
+ mov 36(%esp), %esi
+ mov 40(%esp), %edi
+ movl $__NR_pread64, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %edi
+ popl %esi
+ popl %edx
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/__pwrite64.S b/libc/arch-x86/syscalls/__pwrite64.S
new file mode 100644
index 0000000..28f6536
--- /dev/null
+++ b/libc/arch-x86/syscalls/__pwrite64.S
@@ -0,0 +1,35 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type __pwrite64, @function
+ .globl __pwrite64
+ .align 4
+
+__pwrite64:
+ pushl %ebx
+ pushl %ecx
+ pushl %edx
+ pushl %esi
+ pushl %edi
+ mov 24(%esp), %ebx
+ mov 28(%esp), %ecx
+ mov 32(%esp), %edx
+ mov 36(%esp), %esi
+ mov 40(%esp), %edi
+ movl $__NR_pwrite64, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %edi
+ popl %esi
+ popl %edx
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/timer_create.S b/libc/arch-x86/syscalls/__timer_create.S
index a215210..66b0cea 100644
--- a/libc/arch-x86/syscalls/timer_create.S
+++ b/libc/arch-x86/syscalls/__timer_create.S
@@ -2,11 +2,11 @@
#include <sys/linux-syscalls.h>
.text
- .type timer_create, @function
- .globl timer_create
+ .type __timer_create, @function
+ .globl __timer_create
.align 4
-timer_create:
+__timer_create:
pushl %ebx
pushl %ecx
pushl %edx
diff --git a/libc/arch-x86/syscalls/timer_delete.S b/libc/arch-x86/syscalls/__timer_delete.S
index f939db6..4344d08 100644
--- a/libc/arch-x86/syscalls/timer_delete.S
+++ b/libc/arch-x86/syscalls/__timer_delete.S
@@ -2,11 +2,11 @@
#include <sys/linux-syscalls.h>
.text
- .type timer_delete, @function
- .globl timer_delete
+ .type __timer_delete, @function
+ .globl __timer_delete
.align 4
-timer_delete:
+__timer_delete:
pushl %ebx
mov 8(%esp), %ebx
movl $__NR_timer_delete, %eax
diff --git a/libc/arch-x86/syscalls/timer_getoverrun.S b/libc/arch-x86/syscalls/__timer_getoverrun.S
index 0a1fa1d..4371415 100644
--- a/libc/arch-x86/syscalls/timer_getoverrun.S
+++ b/libc/arch-x86/syscalls/__timer_getoverrun.S
@@ -2,11 +2,11 @@
#include <sys/linux-syscalls.h>
.text
- .type timer_getoverrun, @function
- .globl timer_getoverrun
+ .type __timer_getoverrun, @function
+ .globl __timer_getoverrun
.align 4
-timer_getoverrun:
+__timer_getoverrun:
pushl %ebx
mov 8(%esp), %ebx
movl $__NR_timer_getoverrun, %eax
diff --git a/libc/arch-x86/syscalls/timer_gettime.S b/libc/arch-x86/syscalls/__timer_gettime.S
index 07258be..3923b0a 100644
--- a/libc/arch-x86/syscalls/timer_gettime.S
+++ b/libc/arch-x86/syscalls/__timer_gettime.S
@@ -2,11 +2,11 @@
#include <sys/linux-syscalls.h>
.text
- .type timer_gettime, @function
- .globl timer_gettime
+ .type __timer_gettime, @function
+ .globl __timer_gettime
.align 4
-timer_gettime:
+__timer_gettime:
pushl %ebx
pushl %ecx
mov 12(%esp), %ebx
diff --git a/libc/arch-x86/syscalls/timer_settime.S b/libc/arch-x86/syscalls/__timer_settime.S
index 6c3784a..cabb7df 100644
--- a/libc/arch-x86/syscalls/timer_settime.S
+++ b/libc/arch-x86/syscalls/__timer_settime.S
@@ -2,11 +2,11 @@
#include <sys/linux-syscalls.h>
.text
- .type timer_settime, @function
- .globl timer_settime
+ .type __timer_settime, @function
+ .globl __timer_settime
.align 4
-timer_settime:
+__timer_settime:
pushl %ebx
pushl %ecx
pushl %edx
diff --git a/libc/arch-x86/syscalls/accept.S b/libc/arch-x86/syscalls/accept.S
new file mode 100644
index 0000000..ccd56e7
--- /dev/null
+++ b/libc/arch-x86/syscalls/accept.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type accept, @function
+ .globl accept
+ .align 4
+
+accept:
+ pushl %ebx
+ pushl %ecx
+ mov $5, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/bind.S b/libc/arch-x86/syscalls/bind.S
new file mode 100644
index 0000000..2172cfb
--- /dev/null
+++ b/libc/arch-x86/syscalls/bind.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type bind, @function
+ .globl bind
+ .align 4
+
+bind:
+ pushl %ebx
+ pushl %ecx
+ mov $2, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/connect.S b/libc/arch-x86/syscalls/connect.S
new file mode 100644
index 0000000..8b8ce4e
--- /dev/null
+++ b/libc/arch-x86/syscalls/connect.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type connect, @function
+ .globl connect
+ .align 4
+
+connect:
+ pushl %ebx
+ pushl %ecx
+ mov $3, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/getitimer.S b/libc/arch-x86/syscalls/getitimer.S
new file mode 100644
index 0000000..f170ebf
--- /dev/null
+++ b/libc/arch-x86/syscalls/getitimer.S
@@ -0,0 +1,26 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type getitimer, @function
+ .globl getitimer
+ .align 4
+
+getitimer:
+ pushl %ebx
+ pushl %ecx
+ mov 12(%esp), %ebx
+ mov 16(%esp), %ecx
+ movl $__NR_getitimer, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/getpeername.S b/libc/arch-x86/syscalls/getpeername.S
new file mode 100644
index 0000000..b6f8eb8
--- /dev/null
+++ b/libc/arch-x86/syscalls/getpeername.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type getpeername, @function
+ .globl getpeername
+ .align 4
+
+getpeername:
+ pushl %ebx
+ pushl %ecx
+ mov $7, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/getsockname.S b/libc/arch-x86/syscalls/getsockname.S
new file mode 100644
index 0000000..884acd9
--- /dev/null
+++ b/libc/arch-x86/syscalls/getsockname.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type getsockname, @function
+ .globl getsockname
+ .align 4
+
+getsockname:
+ pushl %ebx
+ pushl %ecx
+ mov $6, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/getsockopt.S b/libc/arch-x86/syscalls/getsockopt.S
new file mode 100644
index 0000000..a606532
--- /dev/null
+++ b/libc/arch-x86/syscalls/getsockopt.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type getsockopt, @function
+ .globl getsockopt
+ .align 4
+
+getsockopt:
+ pushl %ebx
+ pushl %ecx
+ mov $15, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/listen.S b/libc/arch-x86/syscalls/listen.S
new file mode 100644
index 0000000..de310cf
--- /dev/null
+++ b/libc/arch-x86/syscalls/listen.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type listen, @function
+ .globl listen
+ .align 4
+
+listen:
+ pushl %ebx
+ pushl %ecx
+ mov $4, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/recvfrom.S b/libc/arch-x86/syscalls/recvfrom.S
new file mode 100644
index 0000000..3a38518
--- /dev/null
+++ b/libc/arch-x86/syscalls/recvfrom.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type recvfrom, @function
+ .globl recvfrom
+ .align 4
+
+recvfrom:
+ pushl %ebx
+ pushl %ecx
+ mov $12, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/recvmsg.S b/libc/arch-x86/syscalls/recvmsg.S
new file mode 100644
index 0000000..aee69d6
--- /dev/null
+++ b/libc/arch-x86/syscalls/recvmsg.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type recvmsg, @function
+ .globl recvmsg
+ .align 4
+
+recvmsg:
+ pushl %ebx
+ pushl %ecx
+ mov $17, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/sendmsg.S b/libc/arch-x86/syscalls/sendmsg.S
new file mode 100644
index 0000000..5f26623
--- /dev/null
+++ b/libc/arch-x86/syscalls/sendmsg.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type sendmsg, @function
+ .globl sendmsg
+ .align 4
+
+sendmsg:
+ pushl %ebx
+ pushl %ecx
+ mov $16, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/sendto.S b/libc/arch-x86/syscalls/sendto.S
new file mode 100644
index 0000000..d79a2ba
--- /dev/null
+++ b/libc/arch-x86/syscalls/sendto.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type sendto, @function
+ .globl sendto
+ .align 4
+
+sendto:
+ pushl %ebx
+ pushl %ecx
+ mov $11, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/setsockopt.S b/libc/arch-x86/syscalls/setsockopt.S
new file mode 100644
index 0000000..d1c986a
--- /dev/null
+++ b/libc/arch-x86/syscalls/setsockopt.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type setsockopt, @function
+ .globl setsockopt
+ .align 4
+
+setsockopt:
+ pushl %ebx
+ pushl %ecx
+ mov $14, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/shutdown.S b/libc/arch-x86/syscalls/shutdown.S
new file mode 100644
index 0000000..45f0664
--- /dev/null
+++ b/libc/arch-x86/syscalls/shutdown.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type shutdown, @function
+ .globl shutdown
+ .align 4
+
+shutdown:
+ pushl %ebx
+ pushl %ecx
+ mov $13, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/socket.S b/libc/arch-x86/syscalls/socket.S
new file mode 100644
index 0000000..89a8358
--- /dev/null
+++ b/libc/arch-x86/syscalls/socket.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type socket, @function
+ .globl socket
+ .align 4
+
+socket:
+ pushl %ebx
+ pushl %ecx
+ mov $1, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/socketpair.S b/libc/arch-x86/syscalls/socketpair.S
new file mode 100644
index 0000000..0222989
--- /dev/null
+++ b/libc/arch-x86/syscalls/socketpair.S
@@ -0,0 +1,27 @@
+/* autogenerated by gensyscalls.py */
+#include <sys/linux-syscalls.h>
+
+ .text
+ .type socketpair, @function
+ .globl socketpair
+ .align 4
+
+socketpair:
+ pushl %ebx
+ pushl %ecx
+ mov $8, %ebx
+ mov %esp, %ecx
+ addl $12, %ecx
+ movl $__NR_socketcall, %eax
+ int $0x80
+ cmpl $-129, %eax
+ jb 1f
+ negl %eax
+ pushl %eax
+ call __set_errno
+ addl $4, %esp
+ orl $-1, %eax
+1:
+ popl %ecx
+ popl %ebx
+ ret
diff --git a/libc/arch-x86/syscalls/vfork.S b/libc/arch-x86/syscalls/vfork.S
deleted file mode 100644
index 55cb9f0..0000000
--- a/libc/arch-x86/syscalls/vfork.S
+++ /dev/null
@@ -1,23 +0,0 @@
-/* autogenerated by gensyscalls.py */
-#include <sys/linux-syscalls.h>
-
- .text
- .type vfork, @function
- .globl vfork
- .align 4
-
-vfork:
- pushl %ebx
- mov 8(%esp), %ebx
- movl $__NR_vfork, %eax
- int $0x80
- cmpl $-129, %eax
- jb 1f
- negl %eax
- pushl %eax
- call __set_errno
- addl $4, %esp
- orl $-1, %eax
-1:
- popl %ebx
- ret
diff --git a/libc/bionic/fork.c b/libc/bionic/fork.c
new file mode 100644
index 0000000..1c6a4ba
--- /dev/null
+++ b/libc/bionic/fork.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * 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.
+ *
+ * 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
+ * COPYRIGHT OWNER 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.
+ */
+#include <unistd.h>
+#include "pthread_internal.h"
+
+extern int __fork(void);
+
+int fork(void)
+{
+ int ret;
+
+ /* Posix mandates that the timers of a fork child process be
+ * disarmed, but not destroyed. To avoid a race condition, we're
+ * going to stop all timers now, and only re-start them in case
+ * of error, or in the parent process
+ */
+ __timer_table_start_stop(1);
+ ret = __fork();
+ if (ret != 0) { /* not a child process */
+ __timer_table_start_stop(0);
+ }
+ return ret;
+}
diff --git a/libc/bionic/if_indextoname.c b/libc/bionic/if_indextoname.c
new file mode 100644
index 0000000..dc08b28
--- /dev/null
+++ b/libc/bionic/if_indextoname.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * 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.
+ *
+ * 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
+ * COPYRIGHT OWNER 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.
+ */
+
+#include <string.h>
+#include <unistd.h>
+#include <linux/sockios.h>
+#include <net/if.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+
+/*
+ * Map an interface index into its name.
+ * Returns NULL on error.
+ */
+char*
+if_indextoname(unsigned ifindex, char *ifname)
+{
+ int index;
+ int ctl_sock;
+ struct ifreq ifr;
+ char* ret = NULL;
+
+ memset(&ifr, 0, sizeof(struct ifreq));
+ ifr.ifr_ifindex = ifindex;
+
+ if ((ctl_sock = socket(AF_INET, SOCK_DGRAM, 0)) >= 0) {
+ if (ioctl(ctl_sock, SIOCGIFNAME, &ifr) >= 0) {
+ ret = strncpy (ifname, ifr.ifr_name, IFNAMSIZ);
+ } else {
+ /* Posix requires ENXIO */
+ if (errno == ENODEV)
+ errno = ENXIO;
+ }
+ close(ctl_sock);
+ }
+ return ret;
+}
diff --git a/libc/bionic/malloc_leak.c b/libc/bionic/malloc_leak.c
index 821ea23..5ddc913 100644
--- a/libc/bionic/malloc_leak.c
+++ b/libc/bionic/malloc_leak.c
@@ -390,7 +390,15 @@ typedef struct
intptr_t* addrs;
} stack_crawl_state_t;
-static _Unwind_Reason_Code trace_function(_Unwind_Context *context, void *arg)
+
+/* depends how the system includes define this */
+#ifdef HAVE_UNWIND_CONTEXT_STRUCT
+typedef struct _Unwind_Context __unwind_context;
+#else
+typedef _Unwind_Context __unwind_context;
+#endif
+
+static _Unwind_Reason_Code trace_function(__unwind_context *context, void *arg)
{
stack_crawl_state_t* state = (stack_crawl_state_t*)arg;
if (state->count) {
diff --git a/libc/bionic/pthread-timers.c b/libc/bionic/pthread-timers.c
new file mode 100644
index 0000000..a53d04b
--- /dev/null
+++ b/libc/bionic/pthread-timers.c
@@ -0,0 +1,625 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * 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.
+ *
+ * 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
+ * COPYRIGHT OWNER 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.
+ */
+#include "pthread_internal.h"
+#include <linux/time.h>
+#include <string.h>
+#include <errno.h>
+
+/* This file implements the support required to implement SIGEV_THREAD posix
+ * timers. See the following pages for additionnal details:
+ *
+ * www.opengroup.org/onlinepubs/000095399/functions/timer_create.html
+ * www.opengroup.org/onlinepubs/000095399/functions/timer_settime.html
+ * www.opengroup.org/onlinepubs/000095399/functions/xsh_chap02_04.html#tag_02_04_01
+ *
+ * The Linux kernel doesn't support these, so we need to implement them in the
+ * C library. We use a very basic scheme where each timer is associated to a
+ * thread that will loop, waiting for timeouts or messages from the program
+ * corresponding to calls to timer_settime() and timer_delete().
+ *
+ * Note also an important thing: Posix mandates that in the case of fork(),
+ * the timers of the child process should be disarmed, but not deleted.
+ * this is implemented by providing a fork() wrapper (see bionic/fork.c) which
+ * stops all timers before the fork, and only re-start them in case of error
+ * or in the parent process.
+ *
+ * the stop/start is implemented by the __timer_table_start_stop() function
+ * below.
+ */
+
+/* normal (i.e. non-SIGEV_THREAD) timer ids are created directly by the kernel
+ * and are passed as is to/from the caller.
+ *
+ * on the other hand, a SIGEV_THREAD timer ID will have its TIMER_ID_WRAP_BIT
+ * always set to 1. In this implementation, this is always bit 31, which is
+ * guaranteed to never be used by kernel-provided timer ids
+ *
+ * (see code in <kernel>/lib/idr.c, used to manage IDs, to see why)
+ */
+
+#define TIMER_ID_WRAP_BIT 0x80000000
+#define TIMER_ID_WRAP(id) ((timer_t)((id) | TIMER_ID_WRAP_BIT))
+#define TIMER_ID_UNWRAP(id) ((timer_t)((id) & ~TIMER_ID_WRAP_BIT))
+#define TIMER_ID_IS_WRAPPED(id) (((id) & TIMER_ID_WRAP_BIT) != 0)
+
+/* this value is used internally to indicate a 'free' or 'zombie'
+ * thr_timer structure. Here, 'zombie' means that timer_delete()
+ * has been called, but that the corresponding thread hasn't
+ * exited yet.
+ */
+#define TIMER_ID_NONE ((timer_t)0xffffffff)
+
+/* True iff a timer id is valid */
+#define TIMER_ID_IS_VALID(id) ((id) != TIMER_ID_NONE)
+
+/* the maximum value of overrun counters */
+#define DELAYTIMER_MAX 0x7fffffff
+
+#define __likely(x) __builtin_expect(!!(x),1)
+#define __unlikely(x) __builtin_expect(!!(x),0)
+
+typedef struct thr_timer thr_timer_t;
+typedef struct thr_timer_table thr_timer_table_t;
+
+/* The Posix spec says the function receives an unsigned parameter, but
+ * it's really a 'union sigval' a.k.a. sigval_t */
+typedef void (*thr_timer_func_t)( sigval_t );
+
+struct thr_timer {
+ thr_timer_t* next; /* next in free list */
+ timer_t id; /* TIMER_ID_NONE iff free or dying */
+ clockid_t clock;
+ pthread_t thread;
+ pthread_attr_t attributes;
+ thr_timer_func_t callback;
+ sigval_t value;
+
+ /* the following are used to communicate between
+ * the timer thread and the timer_XXX() functions
+ */
+ pthread_mutex_t mutex; /* lock */
+ pthread_cond_t cond; /* signal a state change to thread */
+ int volatile done; /* set by timer_delete */
+ int volatile stopped; /* set by _start_stop() */
+ struct timespec volatile expires; /* next expiration time, or 0 */
+ struct timespec volatile period; /* reload value, or 0 */
+ int volatile overruns; /* current number of overruns */
+};
+
+#define MAX_THREAD_TIMERS 32
+
+struct thr_timer_table {
+ pthread_mutex_t lock;
+ thr_timer_t* free_timer;
+ thr_timer_t timers[ MAX_THREAD_TIMERS ];
+};
+
+/** GLOBAL TABLE OF THREAD TIMERS
+ **/
+
+static void
+thr_timer_table_init( thr_timer_table_t* t )
+{
+ int nn;
+
+ memset(t, 0, sizeof *t);
+ pthread_mutex_init( &t->lock, NULL );
+
+ for (nn = 0; nn < MAX_THREAD_TIMERS; nn++)
+ t->timers[nn].id = TIMER_ID_NONE;
+
+ t->free_timer = &t->timers[0];
+ for (nn = 1; nn < MAX_THREAD_TIMERS; nn++)
+ t->timers[nn-1].next = &t->timers[nn];
+}
+
+
+static thr_timer_t*
+thr_timer_table_alloc( thr_timer_table_t* t )
+{
+ thr_timer_t* timer;
+
+ pthread_mutex_lock(&t->lock);
+ timer = t->free_timer;
+ if (timer != NULL) {
+ t->free_timer = timer->next;
+ timer->next = NULL;
+ timer->id = TIMER_ID_WRAP((timer - t->timers));
+ }
+ pthread_mutex_unlock(&t->lock);
+ return timer;
+}
+
+
+static void
+thr_timer_table_free( thr_timer_table_t* t, thr_timer_t* timer )
+{
+ pthread_mutex_lock( &t->lock );
+ timer->id = TIMER_ID_NONE;
+ timer->thread = 0;
+ timer->next = t->free_timer;
+ t->free_timer = timer;
+ pthread_mutex_unlock( &t->lock );
+}
+
+
+static void
+thr_timer_table_start_stop( thr_timer_table_t* t, int stop )
+{
+ int nn;
+
+ pthread_mutex_lock(&t->lock);
+
+ for (nn = 0; nn < MAX_THREAD_TIMERS; nn++) {
+ thr_timer_t* timer = &t->timers[nn];
+
+ if (TIMER_ID_IS_VALID(timer->id)) {
+ /* tell the thread to start/stop */
+ pthread_mutex_lock(&timer->mutex);
+ timer->stopped = stop;
+ pthread_cond_signal( &timer->cond );
+ pthread_mutex_unlock(&timer->mutex);
+ }
+ }
+ pthread_mutex_unlock(&t->lock);
+}
+
+
+/* convert a timer_id into the corresponding thr_timer_t* pointer
+ * returns NULL if the id is not wrapped or is invalid/free
+ */
+static thr_timer_t*
+thr_timer_table_from_id( thr_timer_table_t* t,
+ timer_t id,
+ int remove )
+{
+ unsigned index;
+ thr_timer_t* timer;
+
+ if (!TIMER_ID_IS_WRAPPED(id))
+ return NULL;
+
+ index = (unsigned) TIMER_ID_UNWRAP(id);
+ if (index >= MAX_THREAD_TIMERS)
+ return NULL;
+
+ pthread_mutex_lock(&t->lock);
+
+ timer = &t->timers[index];
+
+ if (!TIMER_ID_IS_VALID(timer->id)) {
+ timer = NULL;
+ } else {
+ /* if we're removing this timer, clear the id
+ * right now to prevent another thread to
+ * use the same id after the unlock */
+ if (remove)
+ timer->id = TIMER_ID_NONE;
+ }
+ pthread_mutex_unlock(&t->lock);
+
+ return timer;
+}
+
+/* the static timer table */
+
+static pthread_once_t __timer_table_once = PTHREAD_ONCE_INIT;
+static thr_timer_table_t __timer_table[1];
+
+static void
+__timer_table_init( void )
+{
+ thr_timer_table_init( __timer_table );
+}
+
+static thr_timer_table_t*
+__timer_table_get(void)
+{
+ pthread_once( &__timer_table_once, __timer_table_init );
+ return __timer_table;
+}
+
+/** POSIX THREAD TIMERS CLEANUP ON FORK
+ **
+ ** this should be called from the 'fork()' wrapper to stop/start
+ ** all active thread timers. this is used to implement a Posix
+ ** requirements: the timers of fork child processes must be
+ ** disarmed but not deleted.
+ **/
+void
+__timer_table_start_stop( int stop )
+{
+ thr_timer_table_t* table = __timer_table_get();
+ thr_timer_table_start_stop(table, stop);
+}
+
+static thr_timer_t*
+thr_timer_from_id( timer_t id )
+{
+ thr_timer_table_t* table = __timer_table_get();
+ thr_timer_t* timer = thr_timer_table_from_id( table, id, 0 );
+
+ return timer;
+}
+
+
+static __inline__ void
+thr_timer_lock( thr_timer_t* t )
+{
+ pthread_mutex_lock(&t->mutex);
+}
+
+static __inline__ void
+thr_timer_unlock( thr_timer_t* t )
+{
+ pthread_mutex_unlock(&t->mutex);
+}
+
+/** POSIX TIMERS APIs */
+
+/* first, declare the syscall stubs */
+extern int __timer_create( clockid_t, struct sigevent*, timer_t* );
+extern int __timer_delete( timer_t );
+extern int __timer_gettime( timer_t, struct itimerspec* );
+extern int __timer_settime( timer_t, int, const struct itimerspec*, struct itimerspec* );
+extern int __timer_getoverrun(timer_t);
+
+static void* timer_thread_start( void* );
+
+/* then the wrappers themselves */
+int
+timer_create( clockid_t clockid, struct sigevent* evp, timer_t *ptimerid)
+{
+ /* if not a SIGEV_THREAD timer, direct creation by the kernel */
+ if (__likely(evp == NULL || evp->sigev_notify != SIGEV_THREAD))
+ return __timer_create( clockid, evp, ptimerid );
+
+ // check arguments
+ if (evp->sigev_notify_function == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ {
+ struct timespec dummy;
+
+ /* check that the clock id is supported by the kernel */
+ if (clock_gettime( clockid, &dummy ) < 0 && errno == EINVAL )
+ return -1;
+ }
+
+ /* create a new timer and its thread */
+ {
+ thr_timer_table_t* table = __timer_table_get();
+ thr_timer_t* timer = thr_timer_table_alloc( table );
+ struct sigevent evp0;
+
+ if (timer == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ /* copy the thread attributes */
+ if (evp->sigev_notify_attributes == NULL) {
+ pthread_attr_init(&timer->attributes);
+ }
+ else {
+ timer->attributes = ((pthread_attr_t*)evp->sigev_notify_attributes)[0];
+ }
+
+ /* Posix says that the default is PTHREAD_CREATE_DETACHED and
+ * that PTHREAD_CREATE_JOINABLE has undefined behaviour.
+ * So simply always use DETACHED :-)
+ */
+ pthread_attr_setdetachstate(&timer->attributes, PTHREAD_CREATE_DETACHED);
+
+ timer->callback = evp->sigev_notify_function;
+ timer->value = evp->sigev_value;
+ timer->clock = clockid;
+
+ pthread_mutex_init( &timer->mutex, NULL );
+ pthread_cond_init( &timer->cond, NULL );
+
+ timer->done = 0;
+ timer->stopped = 0;
+ timer->expires.tv_sec = timer->expires.tv_nsec = 0;
+ timer->period.tv_sec = timer->period.tv_nsec = 0;
+ timer->overruns = 0;
+
+ /* create the thread */
+ if (pthread_create( &timer->thread, &timer->attributes, timer_thread_start, timer ) < 0) {
+ thr_timer_table_free( __timer_table, timer );
+ errno = ENOMEM;
+ return -1;
+ }
+
+ *ptimerid = timer->id;
+ return 0;
+ }
+}
+
+
+int
+timer_delete( timer_t id )
+{
+ if ( __likely(!TIMER_ID_IS_WRAPPED(id)) )
+ return __timer_delete( id );
+ else
+ {
+ thr_timer_table_t* table = __timer_table_get();
+ thr_timer_t* timer = thr_timer_table_from_id(table, id, 1);
+
+ if (timer == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ /* tell the timer's thread to stop */
+ thr_timer_lock(timer);
+ timer->done = 1;
+ pthread_cond_signal( &timer->cond );
+ thr_timer_unlock(timer);
+
+ /* NOTE: the thread will call __timer_table_free() to free the
+ * timer object. the '1' parameter to thr_timer_table_from_id
+ * above ensured that the object and its timer_id cannot be
+ * reused before that.
+ */
+ return 0;
+ }
+}
+
+/* return the relative time until the next expiration, or 0 if
+ * the timer is disarmed */
+static void
+timer_gettime_internal( thr_timer_t* timer,
+ struct itimerspec* spec)
+{
+ struct timespec diff;
+
+ diff = timer->expires;
+ if (!timespec_is_zero(&diff))
+ {
+ struct timespec now;
+
+ clock_gettime( timer->clock, &now );
+ timespec_sub(&diff, &now);
+
+ /* in case of overrun, return 0 */
+ if (timespec_cmp0(&diff) < 0) {
+ timespec_zero(&diff);
+ }
+ }
+
+ spec->it_value = diff;
+ spec->it_interval = timer->period;
+}
+
+
+int
+timer_gettime( timer_t id, struct itimerspec* ospec )
+{
+ if (ospec == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if ( __likely(!TIMER_ID_IS_WRAPPED(id)) ) {
+ return __timer_gettime( id, ospec );
+ } else {
+ thr_timer_t* timer = thr_timer_from_id(id);
+
+ if (timer == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+ thr_timer_lock(timer);
+ timer_gettime_internal( timer, ospec );
+ thr_timer_unlock(timer);
+ }
+ return 0;
+}
+
+
+int
+timer_settime( timer_t id,
+ int flags,
+ const struct itimerspec* spec,
+ struct itimerspec* ospec )
+{
+ if (spec == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if ( __likely(!TIMER_ID_IS_WRAPPED(id)) ) {
+ return __timer_gettime( id, ospec );
+ } else {
+ thr_timer_t* timer = thr_timer_from_id(id);
+ struct timespec expires, now;
+
+ if (timer == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+ thr_timer_lock(timer);
+
+ /* return current timer value if ospec isn't NULL */
+ if (ospec != NULL) {
+ timer_gettime_internal(timer, ospec );
+ }
+
+ /* compute next expiration time */
+ expires = spec->it_value;
+ clock_gettime( timer->clock, &now );
+ if (!(flags & TIMER_ABSTIME)) {
+ timespec_add(&expires, &now);
+ } else {
+ if (timespec_cmp(&expires, &now) < 0)
+ expires = now;
+ }
+
+ timer->expires = expires;
+ timer->period = spec->it_interval;
+ thr_timer_unlock( timer );
+
+ /* signal the change to the thread */
+ pthread_cond_signal( &timer->cond );
+ }
+ return 0;
+}
+
+
+int
+timer_getoverrun(timer_t id)
+{
+ if ( __likely(!TIMER_ID_IS_WRAPPED(id)) ) {
+ return __timer_getoverrun( id );
+ } else {
+ thr_timer_t* timer = thr_timer_from_id(id);
+ int result;
+
+ if (timer == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ thr_timer_lock(timer);
+ result = timer->overruns;
+ thr_timer_unlock(timer);
+
+ return result;
+ }
+}
+
+
+static void*
+timer_thread_start( void* _arg )
+{
+ thr_timer_t* timer = _arg;
+
+ thr_timer_lock( timer );
+
+ /* we loop until timer->done is set in timer_delete() */
+ while (!timer->done)
+ {
+ struct timespec expires = timer->expires;
+ struct timespec period = timer->period;
+ struct timespec now;
+
+ /* if the timer is stopped or disarmed, wait indefinitely
+ * for a state change from timer_settime/_delete/_start_stop
+ */
+ if ( timer->stopped || timespec_is_zero(&expires) )
+ {
+ pthread_cond_wait( &timer->cond, &timer->mutex );
+ continue;
+ }
+
+ /* otherwise, we need to do a timed wait until either a
+ * state change of the timer expiration time.
+ */
+ clock_gettime(timer->clock, &now);
+
+ if (timespec_cmp( &expires, &now ) > 0)
+ {
+ /* cool, there was no overrun, so compute the
+ * relative timeout as 'now - expires', then wait
+ */
+ int ret;
+ struct timespec diff = now;
+ timespec_sub( &diff, &expires );
+
+ ret = __pthread_cond_timedwait_relative(
+ &timer->cond, &timer->mutex, &diff);
+
+ /* if we didn't timeout, it means that a state change
+ * occured, so reloop to take care of it.
+ */
+ if (ret != ETIMEDOUT)
+ continue;
+ }
+ else
+ {
+ /* overrun was detected before we could wait ! */
+ if (!timespec_is_zero( &period ) )
+ {
+ /* for periodic timers, compute total overrun count */
+ do {
+ timespec_add( &expires, &period );
+ if (timer->overruns < DELAYTIMER_MAX)
+ timer->overruns += 1;
+ } while ( timespec_cmp( &expires, &now ) < 0 );
+
+ /* backtrack the last one, because we're going to
+ * add the same value just a bit later */
+ timespec_sub( &expires, &period );
+ }
+ else
+ {
+ /* for non-periodic timer, things are simple */
+ timer->overruns = 1;
+ }
+ }
+
+ /* if we get there, a timeout was detected.
+ * first reload/disarm the timer has needed
+ */
+ if ( !timespec_is_zero(&period) ) {
+ timespec_add( &expires, &period );
+ } else {
+ timespec_zero( &expires );
+ }
+ timer->expires = expires;
+
+ /* now call the timer callback function. release the
+ * lock to allow the function to modify the timer setting
+ * or call timer_getoverrun().
+ *
+ * NOTE: at this point we trust the callback not to be a
+ * total moron and pthread_kill() the timer thread
+ */
+ thr_timer_unlock(timer);
+ timer->callback( timer->value );
+ thr_timer_lock(timer);
+
+ /* now clear the overruns counter. it only makes sense
+ * within the callback */
+ timer->overruns = 0;
+ }
+
+ thr_timer_unlock( timer );
+
+ /* free the timer object now. there is no need to call
+ * __timer_table_get() since we're guaranteed that __timer_table
+ * is initialized in this thread
+ */
+ thr_timer_table_free(__timer_table, timer);
+
+ return NULL;
+}
diff --git a/libc/bionic/pthread.c b/libc/bionic/pthread.c
index 67fc519..2fd740e 100644
--- a/libc/bionic/pthread.c
+++ b/libc/bionic/pthread.c
@@ -767,6 +767,25 @@ int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type)
return EINVAL;
}
+/* process-shared mutexes are not supported at the moment */
+
+int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared)
+{
+ if (!attr)
+ return EINVAL;
+
+ return (pshared == PTHREAD_PROCESS_PRIVATE) ? 0 : ENOTSUP;
+}
+
+int pthread_mutexattr_getpshared(pthread_mutexattr_t *attr, int *pshared)
+{
+ if (!attr)
+ return EINVAL;
+
+ *pshared = PTHREAD_PROCESS_PRIVATE;
+ return 0;
+}
+
int pthread_mutex_init(pthread_mutex_t *mutex,
const pthread_mutexattr_t *attr)
{
@@ -1120,54 +1139,31 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
return pthread_cond_timedwait(cond, mutex, NULL);
}
-int pthread_cond_timedwait(pthread_cond_t *cond,
- pthread_mutex_t * mutex,
- const struct timespec *abstime)
+int __pthread_cond_timedwait_relative(pthread_cond_t *cond,
+ pthread_mutex_t * mutex,
+ const struct timespec *reltime)
{
- int oldvalue;
- struct timespec ts;
- struct timespec * tsp;
- int status;
-
- if (abstime != NULL) {
- clock_gettime(CLOCK_REALTIME, &ts);
- ts.tv_sec = abstime->tv_sec - ts.tv_sec;
- ts.tv_nsec = abstime->tv_nsec - ts.tv_nsec;
- if (ts.tv_nsec < 0) {
- ts.tv_sec--;
- ts.tv_nsec += 1000000000;
- }
- if((ts.tv_nsec < 0) || (ts.tv_sec < 0)) {
- return ETIMEDOUT;
- }
- tsp = &ts;
- } else {
- tsp = NULL;
- }
-
- oldvalue = cond->value;
+ int status;
+ int oldvalue = cond->value;
pthread_mutex_unlock(mutex);
- status = __futex_wait(&cond->value, oldvalue, tsp);
+ status = __futex_wait(&cond->value, oldvalue, reltime);
pthread_mutex_lock(mutex);
- if(status == (-ETIMEDOUT)) return ETIMEDOUT;
-
+ if (status == (-ETIMEDOUT)) return ETIMEDOUT;
return 0;
}
-
-int pthread_cond_timedwait_monotonic(pthread_cond_t *cond,
- pthread_mutex_t * mutex,
- const struct timespec *abstime)
+int __pthread_cond_timedwait(pthread_cond_t *cond,
+ pthread_mutex_t * mutex,
+ const struct timespec *abstime,
+ clockid_t clock)
{
- int oldvalue;
struct timespec ts;
struct timespec * tsp;
- int status;
if (abstime != NULL) {
- clock_gettime(CLOCK_MONOTONIC, &ts);
+ clock_gettime(clock, &ts);
ts.tv_sec = abstime->tv_sec - ts.tv_sec;
ts.tv_nsec = abstime->tv_nsec - ts.tv_nsec;
if (ts.tv_nsec < 0) {
@@ -1182,15 +1178,22 @@ int pthread_cond_timedwait_monotonic(pthread_cond_t *cond,
tsp = NULL;
}
- oldvalue = cond->value;
+ return __pthread_cond_timedwait_relative(cond, mutex, tsp);
+}
- pthread_mutex_unlock(mutex);
- status = __futex_wait(&cond->value, oldvalue, tsp);
- pthread_mutex_lock(mutex);
+int pthread_cond_timedwait(pthread_cond_t *cond,
+ pthread_mutex_t * mutex,
+ const struct timespec *abstime)
+{
+ return __pthread_cond_timedwait(cond, mutex, abstime, CLOCK_REALTIME);
+}
- if(status == (-ETIMEDOUT)) return ETIMEDOUT;
- return 0;
+int pthread_cond_timedwait_monotonic(pthread_cond_t *cond,
+ pthread_mutex_t * mutex,
+ const struct timespec *abstime)
+{
+ return __pthread_cond_timedwait(cond, mutex, abstime, CLOCK_MONOTONIC);
}
int pthread_cond_timeout_np(pthread_cond_t *cond,
diff --git a/libc/bionic/pthread_internal.h b/libc/bionic/pthread_internal.h
index ac6a5cd..eb4e80c 100644
--- a/libc/bionic/pthread_internal.h
+++ b/libc/bionic/pthread_internal.h
@@ -48,6 +48,68 @@ typedef struct pthread_internal_t
extern void _init_thread(pthread_internal_t * thread, pid_t kernel_id, pthread_attr_t * attr, void * stack_base);
+/* needed by posix-timers.c */
+
+static __inline__ void timespec_add( struct timespec* a, const struct timespec* b )
+{
+ a->tv_sec += b->tv_sec;
+ a->tv_nsec += b->tv_nsec;
+ if (a->tv_nsec >= 1000000000) {
+ a->tv_nsec -= 1000000000;
+ a->tv_sec += 1;
+ }
+}
+
+static __inline__ void timespec_sub( struct timespec* a, const struct timespec* b )
+{
+ a->tv_sec -= b->tv_sec;
+ a->tv_nsec -= b->tv_nsec;
+ if (a->tv_nsec < 0) {
+ a->tv_nsec += 1000000000;
+ a->tv_sec -= 1;
+ }
+}
+
+static __inline__ void timespec_zero( struct timespec* a )
+{
+ a->tv_sec = a->tv_nsec = 0;
+}
+
+static __inline__ int timespec_is_zero( const struct timespec* a )
+{
+ return (a->tv_sec == 0 && a->tv_nsec == 0);
+}
+
+static __inline__ int timespec_cmp( const struct timespec* a, const struct timespec* b )
+{
+ if (a->tv_sec < b->tv_sec) return -1;
+ if (a->tv_sec > b->tv_sec) return +1;
+ if (a->tv_nsec < b->tv_nsec) return -1;
+ if (a->tv_nsec > b->tv_nsec) return +1;
+ return 0;
+}
+
+static __inline__ int timespec_cmp0( const struct timespec* a )
+{
+ if (a->tv_sec < 0) return -1;
+ if (a->tv_sec > 0) return +1;
+ if (a->tv_nsec < 0) return -1;
+ if (a->tv_nsec > 0) return +1;
+ return 0;
+}
+
+extern int __pthread_cond_timedwait(pthread_cond_t*,
+ pthread_mutex_t*,
+ const struct timespec*,
+ clockid_t);
+
+extern int __pthread_cond_timedwait_relative(pthread_cond_t*,
+ pthread_mutex_t*,
+ const struct timespec*);
+
+/* needed by fork.c */
+extern void __timer_table_start_stop(int stop);
+
__END_DECLS
#endif /* _PTHREAD_INTERNAL_H_ */
diff --git a/libc/include/dirent.h b/libc/include/dirent.h
index edfb639..55eef7b 100644
--- a/libc/include/dirent.h
+++ b/libc/include/dirent.h
@@ -68,6 +68,11 @@ extern int readdir_r(DIR* dirp, struct dirent *entry, struct dire
extern int closedir(DIR* dirp);
extern void rewinddir(DIR *dirp);
extern int dirfd(DIR* dirp);
+extern int alphasort(const void *a, const void *b);
+extern int scandir(const char *dir, struct dirent ***namelist,
+ int(*filter)(const struct dirent *),
+ int(*compar)(const struct dirent **,
+ const struct dirent **));
__END_DECLS
diff --git a/libc/include/features.h b/libc/include/features.h
new file mode 100644
index 0000000..343c84d
--- /dev/null
+++ b/libc/include/features.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * 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.
+ *
+ * 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
+ * COPYRIGHT OWNER 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.
+ */
+#ifndef _FEATURES_H_
+#define _FEATURES_H_
+
+/* certain Linux-specific programs expect a <features.h> header file
+ * that defines various features macros
+ */
+
+/* we do include a number of BSD extensions */
+#define _BSD_SOURCE 1
+
+/* we do include a number of GNU extensions */
+#define _GNU_SOURCE 1
+
+/* C95 support */
+#undef __USE_ISOC95
+#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199409L
+# define __USE_ISOC95 1
+#endif
+
+/* C99 support */
+#undef __USE_ISOC99
+#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+# define __USE_ISOC99 1
+#endif
+
+/* Posix support */
+#define __USE_POSIX 1
+#define __USE_POSIX2 1
+#define __USE_XPG 1
+
+#endif /* _FEATURES_H_ */
diff --git a/libc/include/grp.h b/libc/include/grp.h
index 4efc2bd..86d99f3 100644
--- a/libc/include/grp.h
+++ b/libc/include/grp.h
@@ -74,6 +74,9 @@ char *group_from_gid(gid_t, int);
int getgrouplist (const char *user, gid_t group,
gid_t *groups, int *ngroups);
+
+int initgroups (const char *user, gid_t group);
+
__END_DECLS
#endif /* !_GRP_H_ */
diff --git a/libc/include/net/if.h b/libc/include/net/if.h
index 763ac5b..9044fc5 100644
--- a/libc/include/net/if.h
+++ b/libc/include/net/if.h
@@ -37,5 +37,6 @@ __BEGIN_DECLS
* Map an interface name into its corresponding index.
*/
extern unsigned int if_nametoindex(const char *);
+extern char* if_indextoname(unsigned ifindex, char *ifname);
__END_DECLS
diff --git a/libc/include/netdb.h b/libc/include/netdb.h
index 9209590..e824a3a 100644
--- a/libc/include/netdb.h
+++ b/libc/include/netdb.h
@@ -153,9 +153,10 @@ struct addrinfo {
#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
#define EAI_SYSTEM 11 /* system error returned in errno */
-#define EAI_BADHINTS 12
-#define EAI_PROTOCOL 13
-#define EAI_MAX 14
+#define EAI_BADHINTS 12 /* invalid value for hints */
+#define EAI_PROTOCOL 13 /* resolved protocol is unknown */
+#define EAI_OVERFLOW 14 /* argument buffer overflow */
+#define EAI_MAX 15
/*
* Flag values for getaddrinfo()
diff --git a/libc/include/netinet/in.h b/libc/include/netinet/in.h
index 8bffbef..77ae506 100644
--- a/libc/include/netinet/in.h
+++ b/libc/include/netinet/in.h
@@ -31,6 +31,7 @@
#include <endian.h>
#include <linux/socket.h>
#include <linux/in.h>
+#include <linux/in6.h>
__BEGIN_DECLS
diff --git a/libc/include/netinet/in6.h b/libc/include/netinet/in6.h
index 330e718..e645c48 100644
--- a/libc/include/netinet/in6.h
+++ b/libc/include/netinet/in6.h
@@ -36,6 +36,12 @@
(*(const uint32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
(*(const uint32_t *)(const void *)(&(a)->s6_addr[12]) == 0))
+#define IN6_IS_ADDR_LOOPBACK(a) \
+ ((*(const uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
+ (*(const uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
+ (*(const uint32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
+ (*(const uint32_t *)(const void *)(&(a)->s6_addr[12]) == ntohl(1)))
+
#define IN6_IS_ADDR_V4COMPAT(a) \
((*(const uint32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
(*(const uint32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
@@ -54,10 +60,34 @@
#define IN6_IS_ADDR_SITELOCAL(a) \
(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
-#define IN6_IS_ADDR_MULTICAST(a) \
- (((__const uint8_t *) (a))[0] == 0xff)
+#define IN6_IS_ADDR_MULTICAST(a) \
+ (((__const uint8_t *) (a))[0] == 0xff)
+
+
+#define IPV6_ADDR_SCOPE_NODELOCAL 0x01
+#define IPV6_ADDR_SCOPE_INTFACELOCAL 0x01
+#define IPV6_ADDR_SCOPE_LINKLOCAL 0x02
+#define IPV6_ADDR_SCOPE_SITELOCAL 0x05
+#define IPV6_ADDR_SCOPE_ORGLOCAL 0x08
+#define IPV6_ADDR_SCOPE_GLOBAL 0x0e
+
+#define IPV6_ADDR_MC_SCOPE(a) \
+ ((a)->s6_addr[1] & 0x0f)
+
+#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
+ (IN6_IS_ADDR_MULTICAST(a) && \
+ (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_LINKLOCAL))
+#define IN6_IS_ADDR_MC_SITELOCAL(a) \
+ (IN6_IS_ADDR_MULTICAST(a) && \
+ (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_SITELOCAL))
+#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
+ (IN6_IS_ADDR_MULTICAST(a) && \
+ (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_ORGLOCAL))
+
#define IN6_ARE_ADDR_EQUAL(a, b) \
(memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
+#define INET6_ADDRSTRLEN 46
+
#endif /* _NETINET_IN6_H */
diff --git a/libc/include/pthread.h b/libc/include/pthread.h
index f7dd766..9c40099 100644
--- a/libc/include/pthread.h
+++ b/libc/include/pthread.h
@@ -148,6 +148,8 @@ int pthread_mutexattr_init(pthread_mutexattr_t *attr);
int pthread_mutexattr_destroy(pthread_mutexattr_t *attr);
int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *type);
int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type);
+int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared);
+int pthread_mutexattr_getpshared(pthread_mutexattr_t *attr, int *pshared);
int pthread_mutex_init(pthread_mutex_t *mutex,
const pthread_mutexattr_t *attr);
diff --git a/libc/include/signal.h b/libc/include/signal.h
index bdda84f..5540847 100644
--- a/libc/include/signal.h
+++ b/libc/include/signal.h
@@ -114,6 +114,7 @@ extern int sigaction(int, const struct sigaction *, struct sigaction *);
extern int sigpending(sigset_t *);
extern int sigsuspend(const sigset_t *);
extern int sigwait(const sigset_t *set, int *sig);
+extern int siginterrupt(int sig, int flag);
extern int raise(int);
extern int kill(pid_t, int);
diff --git a/libc/include/stdint.h b/libc/include/stdint.h
index 17f32b7..39a8ab8 100644
--- a/libc/include/stdint.h
+++ b/libc/include/stdint.h
@@ -41,6 +41,11 @@
# define __STDINT_MACROS
#endif
+/* the definitions of STDINT_LIMITS depend on those of STDINT_MACROS */
+#if defined __STDINT_LIMITS && !defined __STDINT_MACROS
+# define __STDINT_MACROS
+#endif
+
typedef __int8_t int8_t;
typedef __uint8_t uint8_t;
typedef __int16_t int16_t;
diff --git a/libc/include/stdio.h b/libc/include/stdio.h
index 9f62d63..b3b0adf 100644
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -292,7 +292,7 @@ char *cuserid(char *);
FILE *fdopen(int, const char *);
int fileno(FILE *);
-#if __POSIX_VISIBLE >= 199209
+#if (__POSIX_VISIBLE >= 199209) || 1 /* ANDROID: Bionic does include this */
int pclose(FILE *);
FILE *popen(const char *, const char *);
#endif
@@ -317,12 +317,6 @@ char *tempnam(const char *, const char *);
#endif
__END_DECLS
-#ifndef _POSIX_THREADS
-# define flockfile(fp) /* nothing */
-# define ftrylockfile(fp) (0)
-# define funlockfile(fp) /* nothing */
-#endif
-
#endif /* __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE */
/*
diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h
index ff3c1f7..15925e3 100644
--- a/libc/include/stdlib.h
+++ b/libc/include/stdlib.h
@@ -134,6 +134,32 @@ static __inline__ int grantpt(int __fd)
return 0; /* devpts does this all for us! */
}
+typedef struct {
+ int quot;
+ int rem;
+} div_t;
+
+extern div_t div(int, int);
+
+typedef struct {
+ long int quot;
+ long int rem;
+} ldiv_t;
+
+extern ldiv_t ldiv(long, long);
+
+typedef struct {
+ long long int quot;
+ long long int rem;
+} lldiv_t;
+
+extern lldiv_t lldiv(long long, long long);
+
+/* make STLPort happy */
+extern int mblen(const char *, size_t);
+extern size_t mbstowcs(wchar_t *, const char *, size_t);
+extern int mbtowc(wchar_t *, const char *, size_t);
+
__END_DECLS
#endif /* _STDLIB_H_ */
diff --git a/libc/include/sys/_system_properties.h b/libc/include/sys/_system_properties.h
index a145927..42a7f6c 100644
--- a/libc/include/sys/_system_properties.h
+++ b/libc/include/sys/_system_properties.h
@@ -61,16 +61,16 @@ struct prop_area {
#define SERIAL_DIRTY(serial) ((serial) & 1)
struct prop_info {
- unsigned char name[PROP_NAME_MAX];
+ char name[PROP_NAME_MAX];
unsigned volatile serial;
- unsigned char value[PROP_VALUE_MAX];
+ char value[PROP_VALUE_MAX];
};
struct prop_msg
{
unsigned cmd;
- unsigned char name[PROP_NAME_MAX];
- unsigned char value[PROP_VALUE_MAX];
+ char name[PROP_NAME_MAX];
+ char value[PROP_VALUE_MAX];
};
#define PROP_MSG_SETPROP 1
diff --git a/libc/include/sys/atomics.h b/libc/include/sys/atomics.h
index fbf9b6e..d3fa145 100644
--- a/libc/include/sys/atomics.h
+++ b/libc/include/sys/atomics.h
@@ -29,6 +29,7 @@
#define _SYS_ATOMICS_H
#include <sys/cdefs.h>
+#include <sys/time.h>
__BEGIN_DECLS
diff --git a/libc/include/sys/linux-syscalls.h b/libc/include/sys/linux-syscalls.h
index b6912ad..bed00ce 100644
--- a/libc/include/sys/linux-syscalls.h
+++ b/libc/include/sys/linux-syscalls.h
@@ -37,7 +37,6 @@
#define __NR_getrusage (__NR_SYSCALL_BASE + 77)
#define __NR_setgroups32 (__NR_SYSCALL_BASE + 206)
#define __NR_setpgid (__NR_SYSCALL_BASE + 57)
-#define __NR_vfork (__NR_SYSCALL_BASE + 190)
#define __NR_setregid32 (__NR_SYSCALL_BASE + 204)
#define __NR_chroot (__NR_SYSCALL_BASE + 61)
#define __NR_prctl (__NR_SYSCALL_BASE + 172)
@@ -46,6 +45,8 @@
#define __NR_acct (__NR_SYSCALL_BASE + 51)
#define __NR_read (__NR_SYSCALL_BASE + 3)
#define __NR_write (__NR_SYSCALL_BASE + 4)
+#define __NR_pread64 (__NR_SYSCALL_BASE + 180)
+#define __NR_pwrite64 (__NR_SYSCALL_BASE + 181)
#define __NR_open (__NR_SYSCALL_BASE + 5)
#define __NR_close (__NR_SYSCALL_BASE + 6)
#define __NR_lseek (__NR_SYSCALL_BASE + 19)
@@ -100,6 +101,7 @@
#define __NR_settimeofday (__NR_SYSCALL_BASE + 79)
#define __NR_times (__NR_SYSCALL_BASE + 43)
#define __NR_nanosleep (__NR_SYSCALL_BASE + 162)
+#define __NR_getitimer (__NR_SYSCALL_BASE + 105)
#define __NR_setitimer (__NR_SYSCALL_BASE + 104)
#define __NR_sigaction (__NR_SYSCALL_BASE + 67)
#define __NR_sigprocmask (__NR_SYSCALL_BASE + 126)
@@ -130,6 +132,7 @@
#ifdef __arm__
#define __NR_exit_group (__NR_SYSCALL_BASE + 248)
#define __NR_waitid (__NR_SYSCALL_BASE + 280)
+#define __NR_vfork (__NR_SYSCALL_BASE + 190)
#define __NR_openat (__NR_SYSCALL_BASE + 322)
#define __NR_madvise (__NR_SYSCALL_BASE + 220)
#define __NR_mincore (__NR_SYSCALL_BASE + 219)
@@ -217,6 +220,7 @@
#define __NR_timer_getoverrun (__NR_SYSCALL_BASE + 262)
#define __NR_timer_delete (__NR_SYSCALL_BASE + 263)
#define __NR_utimes (__NR_SYSCALL_BASE + 271)
+#define __NR_socketcall (__NR_SYSCALL_BASE + 102)
#define __NR_epoll_create (__NR_SYSCALL_BASE + 254)
#define __NR_epoll_ctl (__NR_SYSCALL_BASE + 255)
#define __NR_epoll_wait (__NR_SYSCALL_BASE + 256)
diff --git a/libc/include/sys/linux-unistd.h b/libc/include/sys/linux-unistd.h
index a3ffa3e..8539c7b 100644
--- a/libc/include/sys/linux-unistd.h
+++ b/libc/include/sys/linux-unistd.h
@@ -7,7 +7,7 @@ extern "C" {
void _exit (int);
void _exit_thread (int);
-int fork (void);
+pid_t __fork (void);
pid_t _waitpid (pid_t, int*, int, struct rusage*);
int waitid (int, pid_t, struct siginfo_t*, int,void*);
pid_t __clone (int (*fn)(void*), void *child_stack, int flags, void *arg);
@@ -51,6 +51,8 @@ int capset (cap_user_header_t header, const cap_user_data_t data);
int acct (const char* filepath);
ssize_t read (int, void*, size_t);
ssize_t write (int, const void*, size_t);
+ssize_t __pread64 (int, void *, size_t, off_t, off_t);
+ssize_t __pwrite64 (int, void *, size_t, off_t, off_t);
int __open (const char*, int, mode_t);
int __openat (int, const char*, int, mode_t);
int close (int);
@@ -124,12 +126,13 @@ int clock_gettime (clockid_t clk_id, struct timespec *tp);
int clock_settime (clockid_t clk_id, const struct timespec *tp);
int clock_getres (clockid_t clk_id, struct timespec *res);
int clock_nanosleep (const struct timespec *req, struct timespec *rem);
+int getitimer (int, const struct itimerval *);
int setitimer (int, const struct itimerval *, struct itimerval *);
-int timer_create (clockid_t clockid, struct sigevent *evp, timer_t *timerid);
-int timer_settime (timer_t, int, const struct itimerspec*, struct itimerspec*);
-int timer_gettime (timer_t, struct itimerspec*);
-int timer_getoverrun (timer_t);
-int timer_delete (timer_t);
+int __timer_create (clockid_t clockid, struct sigevent *evp, timer_t *timerid);
+int __timer_settime (timer_t, int, const struct itimerspec*, struct itimerspec*);
+int __timer_gettime (timer_t, struct itimerspec*);
+int __timer_getoverrun (timer_t);
+int __timer_delete (timer_t);
int utimes (const char*, const struct timeval tvp[2]);
int sigaction (int, const struct sigaction *, struct sigaction *);
int sigprocmask (int, const sigset_t *, sigset_t *);
@@ -153,6 +156,21 @@ int setsockopt (int, int, int, const void *, socklen_t);
int getsockopt (int, int, int, void *, socklen_t *);
int sendmsg (int, const struct msghdr *, unsigned int);
int recvmsg (int, struct msghdr *, unsigned int);
+int socket (int, int, int);
+int bind (int, struct sockaddr *, int);
+int connect (int, struct sockaddr *, socklen_t);
+int listen (int, int);
+int accept (int, struct sockaddr *, socklen_t *);
+int getsockname (int, struct sockaddr *, socklen_t *);
+int getpeername (int, struct sockaddr *, socklen_t *);
+int socketpair (int, int, int, int*);
+int sendto (int, const void *, size_t, int, const struct sockaddr *, socklen_t);
+int recvfrom (int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *);
+int shutdown (int, int);
+int setsockopt (int, int, int, const void *, socklen_t);
+int getsockopt (int, int, int, void *, socklen_t *);
+int sendmsg (int, const struct msghdr *, unsigned int);
+int recvmsg (int, struct msghdr *, unsigned int);
int sched_setscheduler (pid_t pid, int policy, const struct sched_param *param);
int sched_getscheduler (pid_t pid);
int sched_yield (void);
diff --git a/libc/include/sys/socket.h b/libc/include/sys/socket.h
index 85516fe..208663e 100644
--- a/libc/include/sys/socket.h
+++ b/libc/include/sys/socket.h
@@ -42,7 +42,7 @@ __BEGIN_DECLS
#define SOCK_PACKET 10
#ifdef __i386__
-# define __socketcall extern __cdecl
+# define __socketcall extern __attribute__((__cdecl__))
#else
# define __socketcall extern
#endif
diff --git a/libc/include/sys/timeb.h b/libc/include/sys/timeb.h
new file mode 100644
index 0000000..f2cc39c
--- /dev/null
+++ b/libc/include/sys/timeb.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * 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.
+ *
+ * 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
+ * COPYRIGHT OWNER 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.
+ */
+#ifndef _SYS_TIMEB_H
+#define _SYS_TIMEB_H
+
+#include <sys/time.h>
+
+__BEGIN_DECLS
+
+struct timeb {
+ time_t time;
+ unsigned short millitm;
+ short timezone;
+ short dstflag;
+};
+
+extern int ftime(struct timeb* timebuf);
+
+__END_DECLS
+
+#endif /* _SYS_TIMEB_H */
diff --git a/libc/include/termios.h b/libc/include/termios.h
index 043fe16..ad19089 100644
--- a/libc/include/termios.h
+++ b/libc/include/termios.h
@@ -66,22 +66,11 @@ static __inline__ int tcflush(int fd, int __queue)
return ioctl(fd, TCFLSH, (void *)(intptr_t)__queue);
}
-static __inline__ pid_t tcgetpgrp(int fd)
-{
- pid_t _pid;
- return ioctl(fd, TIOCGPGRP, &_pid) ? (pid_t)-1 : _pid;
-}
-
-static __inline__ int tcsetpgrp(int fd, pid_t _pid)
-{
- return ioctl(fd, TIOCSPGRP, &_pid);
-}
-
static __inline__ pid_t tcgetsid(int fd)
{
pid_t _pid;
return ioctl(fd, TIOCGSID, &_pid) ? (pid_t)-1 : _pid;
-}
+}
static __inline__ int tcsendbreak(int fd, int __duration)
{
diff --git a/libc/include/time.h b/libc/include/time.h
index 5251ff3..35c2358 100644
--- a/libc/include/time.h
+++ b/libc/include/time.h
@@ -64,6 +64,7 @@ struct tm {
#define TM_ZONE tm_zone
extern char* asctime(const struct tm* a);
+extern char* asctime_r(const struct tm* a, char* buf);
/* Return the difference between TIME1 and TIME0. */
extern double difftime (time_t __time1, time_t __time0);
diff --git a/libc/include/unistd.h b/libc/include/unistd.h
index 096b152..b6d70cc 100644
--- a/libc/include/unistd.h
+++ b/libc/include/unistd.h
@@ -184,6 +184,8 @@ extern int daemon(int, int);
/* A special syscall that is only available on the ARM, not x86 function. */
extern int cacheflush(long start, long end, long flags);
+extern pid_t tcgetpgrp(int fd);
+extern int tcsetpgrp(int fd, pid_t _pid);
__END_DECLS
diff --git a/libc/include/wchar.h b/libc/include/wchar.h
index 7ff6ffc..d2d022a 100644
--- a/libc/include/wchar.h
+++ b/libc/include/wchar.h
@@ -44,7 +44,11 @@
__BEGIN_DECLS
-typedef unsigned char wchar_t;
+#ifndef __cplusplus
+/* wchar_t is a builtin keyword of g++ */
+typedef unsigned char wchar_t;
+#endif
+
typedef int wint_t;
typedef struct { int dummy; } mbstate_t;
diff --git a/libc/kernel/README.TXT b/libc/kernel/README.TXT
index da8c5d8..76dfa4d 100644
--- a/libc/kernel/README.TXT
+++ b/libc/kernel/README.TXT
@@ -30,10 +30,6 @@ the generation process works as follows:
*'bionic/kernel/arch-arm/'
contains the ARM-specific directory tree of clean headers.
- * 'bionic/kernel/arch-arm/linux'
- is really a symlink to '../common/linux'. ditto for the 'asm-generic'
- and 'mtd' directories
-
* 'bionic/kernel/arch-arm/asm'
contains the real ARM-specific headers
@@ -59,9 +55,9 @@ the tools you can use are:
content has changed. you can also process more than one file with -u
* tools/update_all.py
- automatically update <linux/_config.h> and all clean headers from
- the content of 'bionic/kernel/original'. this is the script you're
- likely going to run whenever you update the original headers.
+ automatically update all clean headers from the content of
+ 'bionic/kernel/original'. this is the script you're likely going to
+ run whenever you update the original headers.
NOTE:
if ANDROID_PRODUCT_OUT is defined in your environment, both 'clean_header.py'
@@ -74,8 +70,9 @@ NOTE:
HOW TO BUILD BIONIC AND OTHER PROGRAMS WITH THE CLEAN HEADERS:
==============================================================
-simply add bionic/kernel/arch-<yourarch> to your C include path. that should
-be enough. Note that Bionic will not compile properly if you don't.
+add bionic/kernel/common and bionic/kernel/arch-<yourarch> to your C
+include path. that should be enough. Note that Bionic will not compile properly
+if you don't.
HOW TO SUPPORT ANOTHER ARCHITECTURE:
@@ -158,12 +155,12 @@ process the original kernel headers into clean ones:
2. remove variable and function declarations:
this pass scans non-directive text and only keeps things that look like a
- typedef or struct declaration. this allows to get rid of any variable or
- function declaration that should only be used within the kernel anyway
+ typedef/struct/union/enum declaration. this allows to get rid of any variable
+ or function declaration that should only be used within the kernel anyway
(and which normally *should* be guarded in a #ifdef __KERNEL__ ... #endif
block, if the kernel writers were not so messy)
- ther are however a few exceptions: it is seldom useful to keep the definition
+ there are however a few exceptions: it is seldom useful to keep the definition
of some static inline functions performing very simple operations. a good
example is the optimized 32-bit byte-swap function found in
arch-arm/asm/byteorder.h
@@ -177,12 +174,12 @@ process the original kernel headers into clean ones:
using them anyway.
-4. whitespace cleanup:
+3. whitespace cleanup:
the final pass remove any comments and empty lines from the final headers.
-5. add a standard disclaimer:
+4. add a standard disclaimer:
prepended to each generated header, contains a message like
"do not edit directly - file was auto-generated by ...."
@@ -209,8 +206,8 @@ failure or even worse, incorrect behaviour. for example:
C libraries (e.g. glibc5) but result in incorrect behaviour if used
directly.
- e.g. gid_t being defined in <linux/types.h> as a 16-bit type while
- __kernel_gid_t is 32-bit. this results in problems when getgroups() or
+ e.g. gid_t being defined in <linux/types.h> as a 16-bit type while the
+ kernel uses 32-bit ids. this results in problems when getgroups() or
setgroups() are called, since they operate on gid_t arrays.
unfortunately, these headers are also the only source of some really extensive
@@ -226,11 +223,21 @@ by distribution packagers, and generated either manually or with various
scripts. these headers are also tailored to GNU LibC and cannot be reused
easily by Bionic.
-the kernel authors have already stated that they don't want to fix the
-problem, even when someone proposed a patch to start cleaning the official
-headers. from their point of view this is purely a library author problem.
+for a really long period, the kernel authors have stated that they don't want
+to fix the problem, even when someone proposed a patch to start cleaning the
+official headers. from their point of view this is purely a library author
+problem.
+
+fortunately, enlightnment happened, and the kernel now provides a way to
+install a set of "user-friendly" headers that are generated from the official
+ones by stripping the __KERNEL__ protected declarations.
-yeah, right....
+unfortunately, this is not enough for Bionic because the result still contains
+a few broken declarations that are difficult to route around. (see below for
+a little bit of details).
+
+we plan to be able to support these kernel-generated user-land headers in the
+future, but the priority on this issue is very low.
WHAT WE DO:
@@ -266,3 +273,4 @@ issues. for example:
- sometimes, the header is simply incorrect (e.g. it uses a type without
including the header that defines it before-hand)
+
diff --git a/libc/kernel/arch-x86/asm/a.out.h b/libc/kernel/arch-x86/asm/a.out.h
new file mode 100644
index 0000000..6aecff7
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/a.out.h
@@ -0,0 +1,31 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_A_OUT_H
+#define _ASM_X86_A_OUT_H
+
+struct exec
+{
+ unsigned int a_info;
+ unsigned a_text;
+ unsigned a_data;
+ unsigned a_bss;
+ unsigned a_syms;
+ unsigned a_entry;
+ unsigned a_trsize;
+ unsigned a_drsize;
+};
+
+#define N_TRSIZE(a) ((a).a_trsize)
+#define N_DRSIZE(a) ((a).a_drsize)
+#define N_SYMSIZE(a) ((a).a_syms)
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/acpi.h b/libc/kernel/arch-x86/asm/acpi.h
new file mode 100644
index 0000000..0115ce9
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/acpi.h
@@ -0,0 +1,19 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_ACPI_H
+#define _ASM_X86_ACPI_H
+
+#include "acpi_64.h"
+
+#include <asm/processor.h>
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/acpi_32.h b/libc/kernel/arch-x86/asm/acpi_32.h
new file mode 100644
index 0000000..fe0043c
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/acpi_32.h
@@ -0,0 +1,15 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_ACPI_H
+#define _ASM_ACPI_H
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/alternative.h b/libc/kernel/arch-x86/asm/alternative.h
new file mode 100644
index 0000000..17c1dc5
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/alternative.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "alternative_64.h"
diff --git a/libc/kernel/arch-x86/asm/alternative_32.h b/libc/kernel/arch-x86/asm/alternative_32.h
new file mode 100644
index 0000000..ef13111
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/alternative_32.h
@@ -0,0 +1,38 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _I386_ALTERNATIVE_H
+#define _I386_ALTERNATIVE_H
+
+#include <asm/types.h>
+#include <linux/stddef.h>
+#include <linux/types.h>
+
+struct alt_instr {
+ u8 *instr;
+ u8 *replacement;
+ u8 cpuid;
+ u8 instrlen;
+ u8 replacementlen;
+ u8 pad;
+};
+
+struct module;
+#define alternative(oldinstr, newinstr, feature) asm volatile ("661:\n\t" oldinstr "\n662:\n" ".section .altinstructions,\"a\"\n" " .align 4\n" " .long 661b\n" " .long 663f\n" " .byte %c0\n" " .byte 662b-661b\n" " .byte 664f-663f\n" ".previous\n" ".section .altinstr_replacement,\"ax\"\n" "663:\n\t" newinstr "\n664:\n" ".previous" :: "i" (feature) : "memory")
+#define alternative_input(oldinstr, newinstr, feature, input...) asm volatile ("661:\n\t" oldinstr "\n662:\n" ".section .altinstructions,\"a\"\n" " .align 4\n" " .long 661b\n" " .long 663f\n" " .byte %c0\n" " .byte 662b-661b\n" " .byte 664f-663f\n" ".previous\n" ".section .altinstr_replacement,\"ax\"\n" "663:\n\t" newinstr "\n664:\n" ".previous" :: "i" (feature), ##input)
+#define alternative_io(oldinstr, newinstr, feature, output, input...) asm volatile ("661:\n\t" oldinstr "\n662:\n" ".section .altinstructions,\"a\"\n" " .align 4\n" " .long 661b\n" " .long 663f\n" " .byte %c[feat]\n" " .byte 662b-661b\n" " .byte 664f-663f\n" ".previous\n" ".section .altinstr_replacement,\"ax\"\n" "663:\n\t" newinstr "\n664:\n" ".previous" : output : [feat] "i" (feature), ##input)
+#define ASM_OUTPUT2(a, b) a, b
+#define LOCK_PREFIX ""
+
+#define __parainstructions NULL
+#define __parainstructions_end NULL
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/apic.h b/libc/kernel/arch-x86/asm/apic.h
new file mode 100644
index 0000000..5cb7181
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/apic.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "apic_64.h"
diff --git a/libc/kernel/arch-x86/asm/apic_32.h b/libc/kernel/arch-x86/asm/apic_32.h
new file mode 100644
index 0000000..02c9d9b
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/apic_32.h
@@ -0,0 +1,31 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_APIC_H
+#define __ASM_APIC_H
+
+#include <linux/pm.h>
+#include <linux/delay.h>
+#include <asm/fixmap.h>
+#include <asm/apicdef.h>
+#include <asm/processor.h>
+#include <asm/system.h>
+
+#define Dprintk(x...)
+
+#define APIC_QUIET 0
+#define APIC_VERBOSE 1
+#define APIC_DEBUG 2
+
+#define apic_printk(v, s, a...) do { if ((v) <= apic_verbosity) printk(s, ##a); } while (0)
+
+#define local_apic_timer_c2_ok 1
+#endif
diff --git a/libc/kernel/arch-x86/asm/apicdef.h b/libc/kernel/arch-x86/asm/apicdef.h
new file mode 100644
index 0000000..bd19f5a
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/apicdef.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "apicdef_64.h"
diff --git a/libc/kernel/arch-x86/asm/apicdef_32.h b/libc/kernel/arch-x86/asm/apicdef_32.h
new file mode 100644
index 0000000..a4a5edb
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/apicdef_32.h
@@ -0,0 +1,372 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_APICDEF_H
+#define __ASM_APICDEF_H
+
+#define APIC_DEFAULT_PHYS_BASE 0xfee00000
+
+#define APIC_ID 0x20
+#define APIC_LVR 0x30
+#define APIC_LVR_MASK 0xFF00FF
+#define GET_APIC_VERSION(x) ((x)&0xFF)
+#define GET_APIC_MAXLVT(x) (((x)>>16)&0xFF)
+#define APIC_INTEGRATED(x) ((x)&0xF0)
+#define APIC_XAPIC(x) ((x) >= 0x14)
+#define APIC_TASKPRI 0x80
+#define APIC_TPRI_MASK 0xFF
+#define APIC_ARBPRI 0x90
+#define APIC_ARBPRI_MASK 0xFF
+#define APIC_PROCPRI 0xA0
+#define APIC_EOI 0xB0
+#define APIC_EIO_ACK 0x0
+#define APIC_RRR 0xC0
+#define APIC_LDR 0xD0
+#define APIC_LDR_MASK (0xFF<<24)
+#define GET_APIC_LOGICAL_ID(x) (((x)>>24)&0xFF)
+#define SET_APIC_LOGICAL_ID(x) (((x)<<24))
+#define APIC_ALL_CPUS 0xFF
+#define APIC_DFR 0xE0
+#define APIC_DFR_CLUSTER 0x0FFFFFFFul
+#define APIC_DFR_FLAT 0xFFFFFFFFul
+#define APIC_SPIV 0xF0
+#define APIC_SPIV_FOCUS_DISABLED (1<<9)
+#define APIC_SPIV_APIC_ENABLED (1<<8)
+#define APIC_ISR 0x100
+#define APIC_ISR_NR 0x8
+#define APIC_TMR 0x180
+#define APIC_IRR 0x200
+#define APIC_ESR 0x280
+#define APIC_ESR_SEND_CS 0x00001
+#define APIC_ESR_RECV_CS 0x00002
+#define APIC_ESR_SEND_ACC 0x00004
+#define APIC_ESR_RECV_ACC 0x00008
+#define APIC_ESR_SENDILL 0x00020
+#define APIC_ESR_RECVILL 0x00040
+#define APIC_ESR_ILLREGA 0x00080
+#define APIC_ICR 0x300
+#define APIC_DEST_SELF 0x40000
+#define APIC_DEST_ALLINC 0x80000
+#define APIC_DEST_ALLBUT 0xC0000
+#define APIC_ICR_RR_MASK 0x30000
+#define APIC_ICR_RR_INVALID 0x00000
+#define APIC_ICR_RR_INPROG 0x10000
+#define APIC_ICR_RR_VALID 0x20000
+#define APIC_INT_LEVELTRIG 0x08000
+#define APIC_INT_ASSERT 0x04000
+#define APIC_ICR_BUSY 0x01000
+#define APIC_DEST_LOGICAL 0x00800
+#define APIC_DM_FIXED 0x00000
+#define APIC_DM_LOWEST 0x00100
+#define APIC_DM_SMI 0x00200
+#define APIC_DM_REMRD 0x00300
+#define APIC_DM_NMI 0x00400
+#define APIC_DM_INIT 0x00500
+#define APIC_DM_STARTUP 0x00600
+#define APIC_DM_EXTINT 0x00700
+#define APIC_VECTOR_MASK 0x000FF
+#define APIC_ICR2 0x310
+#define GET_APIC_DEST_FIELD(x) (((x)>>24)&0xFF)
+#define SET_APIC_DEST_FIELD(x) ((x)<<24)
+#define APIC_LVTT 0x320
+#define APIC_LVTTHMR 0x330
+#define APIC_LVTPC 0x340
+#define APIC_LVT0 0x350
+#define APIC_LVT_TIMER_BASE_MASK (0x3<<18)
+#define GET_APIC_TIMER_BASE(x) (((x)>>18)&0x3)
+#define SET_APIC_TIMER_BASE(x) (((x)<<18))
+#define APIC_TIMER_BASE_CLKIN 0x0
+#define APIC_TIMER_BASE_TMBASE 0x1
+#define APIC_TIMER_BASE_DIV 0x2
+#define APIC_LVT_TIMER_PERIODIC (1<<17)
+#define APIC_LVT_MASKED (1<<16)
+#define APIC_LVT_LEVEL_TRIGGER (1<<15)
+#define APIC_LVT_REMOTE_IRR (1<<14)
+#define APIC_INPUT_POLARITY (1<<13)
+#define APIC_SEND_PENDING (1<<12)
+#define APIC_MODE_MASK 0x700
+#define GET_APIC_DELIVERY_MODE(x) (((x)>>8)&0x7)
+#define SET_APIC_DELIVERY_MODE(x,y) (((x)&~0x700)|((y)<<8))
+#define APIC_MODE_FIXED 0x0
+#define APIC_MODE_NMI 0x4
+#define APIC_MODE_EXTINT 0x7
+#define APIC_LVT1 0x360
+#define APIC_LVTERR 0x370
+#define APIC_TMICT 0x380
+#define APIC_TMCCT 0x390
+#define APIC_TDCR 0x3E0
+#define APIC_TDR_DIV_TMBASE (1<<2)
+#define APIC_TDR_DIV_1 0xB
+#define APIC_TDR_DIV_2 0x0
+#define APIC_TDR_DIV_4 0x1
+#define APIC_TDR_DIV_8 0x2
+#define APIC_TDR_DIV_16 0x3
+#define APIC_TDR_DIV_32 0x8
+#define APIC_TDR_DIV_64 0x9
+#define APIC_TDR_DIV_128 0xA
+
+#define APIC_BASE (fix_to_virt(FIX_APIC_BASE))
+
+#define MAX_IO_APICS 64
+
+#define u32 unsigned int
+
+struct local_apic {
+
+ struct { u32 __reserved[4]; } __reserved_01;
+
+ struct { u32 __reserved[4]; } __reserved_02;
+
+ struct {
+ u32 __reserved_1 : 24,
+ phys_apic_id : 4,
+ __reserved_2 : 4;
+ u32 __reserved[3];
+ } id;
+
+ const
+ struct {
+ u32 version : 8,
+ __reserved_1 : 8,
+ max_lvt : 8,
+ __reserved_2 : 8;
+ u32 __reserved[3];
+ } version;
+
+ struct { u32 __reserved[4]; } __reserved_03;
+
+ struct { u32 __reserved[4]; } __reserved_04;
+
+ struct { u32 __reserved[4]; } __reserved_05;
+
+ struct { u32 __reserved[4]; } __reserved_06;
+
+ struct {
+ u32 priority : 8,
+ __reserved_1 : 24;
+ u32 __reserved_2[3];
+ } tpr;
+
+ const
+ struct {
+ u32 priority : 8,
+ __reserved_1 : 24;
+ u32 __reserved_2[3];
+ } apr;
+
+ const
+ struct {
+ u32 priority : 8,
+ __reserved_1 : 24;
+ u32 __reserved_2[3];
+ } ppr;
+
+ struct {
+ u32 eoi;
+ u32 __reserved[3];
+ } eoi;
+
+ struct { u32 __reserved[4]; } __reserved_07;
+
+ struct {
+ u32 __reserved_1 : 24,
+ logical_dest : 8;
+ u32 __reserved_2[3];
+ } ldr;
+
+ struct {
+ u32 __reserved_1 : 28,
+ model : 4;
+ u32 __reserved_2[3];
+ } dfr;
+
+ struct {
+ u32 spurious_vector : 8,
+ apic_enabled : 1,
+ focus_cpu : 1,
+ __reserved_2 : 22;
+ u32 __reserved_3[3];
+ } svr;
+
+ struct {
+ u32 bitfield;
+ u32 __reserved[3];
+ } isr [8];
+
+ struct {
+ u32 bitfield;
+ u32 __reserved[3];
+ } tmr [8];
+
+ struct {
+ u32 bitfield;
+ u32 __reserved[3];
+ } irr [8];
+
+ union {
+ struct {
+ u32 send_cs_error : 1,
+ receive_cs_error : 1,
+ send_accept_error : 1,
+ receive_accept_error : 1,
+ __reserved_1 : 1,
+ send_illegal_vector : 1,
+ receive_illegal_vector : 1,
+ illegal_register_address : 1,
+ __reserved_2 : 24;
+ u32 __reserved_3[3];
+ } error_bits;
+ struct {
+ u32 errors;
+ u32 __reserved_3[3];
+ } all_errors;
+ } esr;
+
+ struct { u32 __reserved[4]; } __reserved_08;
+
+ struct { u32 __reserved[4]; } __reserved_09;
+
+ struct { u32 __reserved[4]; } __reserved_10;
+
+ struct { u32 __reserved[4]; } __reserved_11;
+
+ struct { u32 __reserved[4]; } __reserved_12;
+
+ struct { u32 __reserved[4]; } __reserved_13;
+
+ struct { u32 __reserved[4]; } __reserved_14;
+
+ struct {
+ u32 vector : 8,
+ delivery_mode : 3,
+ destination_mode : 1,
+ delivery_status : 1,
+ __reserved_1 : 1,
+ level : 1,
+ trigger : 1,
+ __reserved_2 : 2,
+ shorthand : 2,
+ __reserved_3 : 12;
+ u32 __reserved_4[3];
+ } icr1;
+
+ struct {
+ union {
+ u32 __reserved_1 : 24,
+ phys_dest : 4,
+ __reserved_2 : 4;
+ u32 __reserved_3 : 24,
+ logical_dest : 8;
+ } dest;
+ u32 __reserved_4[3];
+ } icr2;
+
+ struct {
+ u32 vector : 8,
+ __reserved_1 : 4,
+ delivery_status : 1,
+ __reserved_2 : 3,
+ mask : 1,
+ timer_mode : 1,
+ __reserved_3 : 14;
+ u32 __reserved_4[3];
+ } lvt_timer;
+
+ struct {
+ u32 vector : 8,
+ delivery_mode : 3,
+ __reserved_1 : 1,
+ delivery_status : 1,
+ __reserved_2 : 3,
+ mask : 1,
+ __reserved_3 : 15;
+ u32 __reserved_4[3];
+ } lvt_thermal;
+
+ struct {
+ u32 vector : 8,
+ delivery_mode : 3,
+ __reserved_1 : 1,
+ delivery_status : 1,
+ __reserved_2 : 3,
+ mask : 1,
+ __reserved_3 : 15;
+ u32 __reserved_4[3];
+ } lvt_pc;
+
+ struct {
+ u32 vector : 8,
+ delivery_mode : 3,
+ __reserved_1 : 1,
+ delivery_status : 1,
+ polarity : 1,
+ remote_irr : 1,
+ trigger : 1,
+ mask : 1,
+ __reserved_2 : 15;
+ u32 __reserved_3[3];
+ } lvt_lint0;
+
+ struct {
+ u32 vector : 8,
+ delivery_mode : 3,
+ __reserved_1 : 1,
+ delivery_status : 1,
+ polarity : 1,
+ remote_irr : 1,
+ trigger : 1,
+ mask : 1,
+ __reserved_2 : 15;
+ u32 __reserved_3[3];
+ } lvt_lint1;
+
+ struct {
+ u32 vector : 8,
+ __reserved_1 : 4,
+ delivery_status : 1,
+ __reserved_2 : 3,
+ mask : 1,
+ __reserved_3 : 15;
+ u32 __reserved_4[3];
+ } lvt_error;
+
+ struct {
+ u32 initial_count;
+ u32 __reserved_2[3];
+ } timer_icr;
+
+ const
+ struct {
+ u32 curr_count;
+ u32 __reserved_2[3];
+ } timer_ccr;
+
+ struct { u32 __reserved[4]; } __reserved_16;
+
+ struct { u32 __reserved[4]; } __reserved_17;
+
+ struct { u32 __reserved[4]; } __reserved_18;
+
+ struct { u32 __reserved[4]; } __reserved_19;
+
+ struct {
+ u32 divisor : 4,
+ __reserved_1 : 28;
+ u32 __reserved_2[3];
+ } timer_dcr;
+
+ struct { u32 __reserved[4]; } __reserved_20;
+
+} __attribute__ ((packed));
+
+#undef u32
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/atomic.h b/libc/kernel/arch-x86/asm/atomic.h
new file mode 100644
index 0000000..00289cf
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/atomic.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "atomic_64.h"
diff --git a/libc/kernel/arch-x86/asm/atomic_32.h b/libc/kernel/arch-x86/asm/atomic_32.h
new file mode 100644
index 0000000..677aac8
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/atomic_32.h
@@ -0,0 +1,39 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ARCH_I386_ATOMIC__
+#define __ARCH_I386_ATOMIC__
+
+#include <linux/compiler.h>
+#include <asm/processor.h>
+#include <asm/cmpxchg.h>
+
+typedef struct { int counter; } atomic_t;
+
+#define ATOMIC_INIT(i) { (i) }
+
+#define atomic_read(v) ((v)->counter)
+
+#define atomic_set(v,i) (((v)->counter) = (i))
+
+#define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new)))
+#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
+#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
+#define atomic_inc_return(v) (atomic_add_return(1,v))
+#define atomic_dec_return(v) (atomic_sub_return(1,v))
+#define atomic_clear_mask(mask, addr) __asm__ __volatile__(LOCK_PREFIX "andl %0,%1" : : "r" (~(mask)),"m" (*addr) : "memory")
+#define atomic_set_mask(mask, addr) __asm__ __volatile__(LOCK_PREFIX "orl %0,%1" : : "r" (mask),"m" (*(addr)) : "memory")
+#define smp_mb__before_atomic_dec() barrier()
+#define smp_mb__after_atomic_dec() barrier()
+#define smp_mb__before_atomic_inc() barrier()
+#define smp_mb__after_atomic_inc() barrier()
+#include <asm-generic/atomic.h>
+#endif
diff --git a/libc/kernel/arch-x86/asm/auxvec.h b/libc/kernel/arch-x86/asm/auxvec.h
new file mode 100644
index 0000000..f065eb1
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/auxvec.h
@@ -0,0 +1,20 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_AUXVEC_H
+#define _ASM_X86_AUXVEC_H
+
+#ifdef __i386__
+#define AT_SYSINFO 32
+#endif
+#define AT_SYSINFO_EHDR 33
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/bitops.h b/libc/kernel/arch-x86/asm/bitops.h
new file mode 100644
index 0000000..3b58565
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/bitops.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "bitops_64.h"
diff --git a/libc/kernel/arch-x86/asm/bitops_32.h b/libc/kernel/arch-x86/asm/bitops_32.h
new file mode 100644
index 0000000..fa77fe2
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/bitops_32.h
@@ -0,0 +1,30 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _I386_BITOPS_H
+#define _I386_BITOPS_H
+
+#ifndef _LINUX_BITOPS_H
+#error only <linux/bitops.h> can be included directly
+#endif
+
+#include <linux/compiler.h>
+#include <asm/alternative.h>
+
+#define ADDR (*(volatile long *) addr)
+
+#define smp_mb__before_clear_bit() barrier()
+#define smp_mb__after_clear_bit() barrier()
+#define test_bit(nr,addr) (__builtin_constant_p(nr) ? constant_test_bit((nr),(addr)) : variable_test_bit((nr),(addr)))
+#undef ADDR
+
+#include <asm-generic/bitops/fls64.h>
+#endif
diff --git a/libc/kernel/arch-x86/asm/bug.h b/libc/kernel/arch-x86/asm/bug.h
new file mode 100644
index 0000000..9247022
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/bug.h
@@ -0,0 +1,16 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_BUG_H
+#define _ASM_X86_BUG_H
+
+#include <asm-generic/bug.h>
+#endif
diff --git a/libc/kernel/arch-x86/asm/byteorder.h b/libc/kernel/arch-x86/asm/byteorder.h
new file mode 100644
index 0000000..a839798
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/byteorder.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_BYTEORDER_H
+#define _ASM_X86_BYTEORDER_H
+
+#include <asm/types.h>
+#include <linux/compiler.h>
+
+#ifdef __GNUC__
+
+#ifdef __i386__
+
+static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
+{
+ __asm__("xchgb %b0,%h0\n\t"
+ "rorl $16,%0\n\t"
+ "xchgb %b0,%h0"
+ :"=q" (x)
+ : "0" (x));
+ return x;
+}
+
+static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 val)
+{
+ union {
+ struct { __u32 a,b; } s;
+ __u64 u;
+ } v;
+ v.u = val;
+ v.s.a = ___arch__swab32(v.s.a);
+ v.s.b = ___arch__swab32(v.s.b);
+ __asm__("xchgl %0,%1" : "=r" (v.s.a), "=r" (v.s.b) : "0" (v.s.a), "1" (v.s.b));
+ return v.u;
+}
+
+#else
+
+static __inline__ __attribute_const__ __u64 ___arch__swab64(__u64 x)
+{
+ __asm__("bswapq %0" : "=r" (x) : "0" (x));
+ return x;
+}
+
+static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x)
+{
+ __asm__("bswapl %0" : "=r" (x) : "0" (x));
+ return x;
+}
+
+#endif
+
+#define __arch__swab64(x) ___arch__swab64(x)
+#define __arch__swab32(x) ___arch__swab32(x)
+
+#define __BYTEORDER_HAS_U64__
+
+#endif
+
+#include <linux/byteorder/little_endian.h>
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/cache.h b/libc/kernel/arch-x86/asm/cache.h
new file mode 100644
index 0000000..2766a71
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/cache.h
@@ -0,0 +1,20 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ARCH_X86_CACHE_H
+#define _ARCH_X86_CACHE_H
+
+#define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
+#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
+
+#define __read_mostly __attribute__((__section__(".data.read_mostly")))
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/cacheflush.h b/libc/kernel/arch-x86/asm/cacheflush.h
new file mode 100644
index 0000000..028277b
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/cacheflush.h
@@ -0,0 +1,34 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_CACHEFLUSH_H
+#define _ASM_X86_CACHEFLUSH_H
+
+#include <linux/mm.h>
+
+#define flush_cache_all() do { } while (0)
+#define flush_cache_mm(mm) do { } while (0)
+#define flush_cache_dup_mm(mm) do { } while (0)
+#define flush_cache_range(vma, start, end) do { } while (0)
+#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
+#define flush_dcache_page(page) do { } while (0)
+#define flush_dcache_mmap_lock(mapping) do { } while (0)
+#define flush_dcache_mmap_unlock(mapping) do { } while (0)
+#define flush_icache_range(start, end) do { } while (0)
+#define flush_icache_page(vma,pg) do { } while (0)
+#define flush_icache_user_range(vma,pg,adr,len) do { } while (0)
+#define flush_cache_vmap(start, end) do { } while (0)
+#define flush_cache_vunmap(start, end) do { } while (0)
+
+#define copy_to_user_page(vma, page, vaddr, dst, src, len) memcpy(dst, src, len)
+#define copy_from_user_page(vma, page, vaddr, dst, src, len) memcpy(dst, src, len)
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/cmpxchg.h b/libc/kernel/arch-x86/asm/cmpxchg.h
new file mode 100644
index 0000000..de059a2
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/cmpxchg.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "cmpxchg_64.h"
diff --git a/libc/kernel/arch-x86/asm/cmpxchg_32.h b/libc/kernel/arch-x86/asm/cmpxchg_32.h
new file mode 100644
index 0000000..3632f4c
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/cmpxchg_32.h
@@ -0,0 +1,31 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_CMPXCHG_H
+#define __ASM_CMPXCHG_H
+
+#include <linux/bitops.h>
+
+#define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr))))
+
+struct __xchg_dummy { unsigned long a[100]; };
+#define __xg(x) ((struct __xchg_dummy *)(x))
+
+#define ll_low(x) *(((unsigned int*)&(x))+0)
+#define ll_high(x) *(((unsigned int*)&(x))+1)
+#define set_64bit(ptr,value) (__builtin_constant_p(value) ? __set_64bit_constant(ptr, value) : __set_64bit_var(ptr, value) )
+#define _set_64bit(ptr,value) (__builtin_constant_p(value) ? __set_64bit(ptr, (unsigned int)(value), (unsigned int)((value)>>32ULL) ) : __set_64bit(ptr, ll_low(value), ll_high(value)) )
+
+#define cmpxchg(ptr,o,n) ({ __typeof__(*(ptr)) __ret; if (likely(boot_cpu_data.x86 > 3)) __ret = __cmpxchg((ptr), (unsigned long)(o), (unsigned long)(n), sizeof(*(ptr))); else __ret = cmpxchg_386((ptr), (unsigned long)(o), (unsigned long)(n), sizeof(*(ptr))); __ret; })
+#define cmpxchg_local(ptr,o,n) ({ __typeof__(*(ptr)) __ret; if (likely(boot_cpu_data.x86 > 3)) __ret = __cmpxchg_local((ptr), (unsigned long)(o), (unsigned long)(n), sizeof(*(ptr))); else __ret = cmpxchg_386((ptr), (unsigned long)(o), (unsigned long)(n), sizeof(*(ptr))); __ret; })
+#define cmpxchg64(ptr,o,n) ((__typeof__(*(ptr)))__cmpxchg64((ptr),(unsigned long long)(o), (unsigned long long)(n)))
+#define cmpxchg64_local(ptr,o,n) ((__typeof__(*(ptr)))__cmpxchg64_local((ptr),(unsigned long long)(o), (unsigned long long)(n)))
+#endif
diff --git a/libc/kernel/arch-x86/asm/cpufeature.h b/libc/kernel/arch-x86/asm/cpufeature.h
new file mode 100644
index 0000000..47af457
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/cpufeature.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "cpufeature_64.h"
diff --git a/libc/kernel/arch-x86/asm/cpufeature_32.h b/libc/kernel/arch-x86/asm/cpufeature_32.h
new file mode 100644
index 0000000..a8ebc40
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/cpufeature_32.h
@@ -0,0 +1,151 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_I386_CPUFEATURE_H
+#define __ASM_I386_CPUFEATURE_H
+
+#ifndef __ASSEMBLY__
+#include <linux/bitops.h>
+#endif
+#include <asm/required-features.h>
+
+#define NCAPINTS 8
+
+#define X86_FEATURE_FPU (0*32+ 0)
+#define X86_FEATURE_VME (0*32+ 1)
+#define X86_FEATURE_DE (0*32+ 2)
+#define X86_FEATURE_PSE (0*32+ 3)
+#define X86_FEATURE_TSC (0*32+ 4)
+#define X86_FEATURE_MSR (0*32+ 5)
+#define X86_FEATURE_PAE (0*32+ 6)
+#define X86_FEATURE_MCE (0*32+ 7)
+#define X86_FEATURE_CX8 (0*32+ 8)
+#define X86_FEATURE_APIC (0*32+ 9)
+#define X86_FEATURE_SEP (0*32+11)
+#define X86_FEATURE_MTRR (0*32+12)
+#define X86_FEATURE_PGE (0*32+13)
+#define X86_FEATURE_MCA (0*32+14)
+#define X86_FEATURE_CMOV (0*32+15)
+#define X86_FEATURE_PAT (0*32+16)
+#define X86_FEATURE_PSE36 (0*32+17)
+#define X86_FEATURE_PN (0*32+18)
+#define X86_FEATURE_CLFLSH (0*32+19)
+#define X86_FEATURE_DS (0*32+21)
+#define X86_FEATURE_ACPI (0*32+22)
+#define X86_FEATURE_MMX (0*32+23)
+#define X86_FEATURE_FXSR (0*32+24)
+
+#define X86_FEATURE_XMM (0*32+25)
+#define X86_FEATURE_XMM2 (0*32+26)
+#define X86_FEATURE_SELFSNOOP (0*32+27)
+#define X86_FEATURE_HT (0*32+28)
+#define X86_FEATURE_ACC (0*32+29)
+#define X86_FEATURE_IA64 (0*32+30)
+
+#define X86_FEATURE_SYSCALL (1*32+11)
+#define X86_FEATURE_MP (1*32+19)
+#define X86_FEATURE_NX (1*32+20)
+#define X86_FEATURE_MMXEXT (1*32+22)
+#define X86_FEATURE_RDTSCP (1*32+27)
+#define X86_FEATURE_LM (1*32+29)
+#define X86_FEATURE_3DNOWEXT (1*32+30)
+#define X86_FEATURE_3DNOW (1*32+31)
+
+#define X86_FEATURE_RECOVERY (2*32+ 0)
+#define X86_FEATURE_LONGRUN (2*32+ 1)
+#define X86_FEATURE_LRTI (2*32+ 3)
+
+#define X86_FEATURE_CXMMX (3*32+ 0)
+#define X86_FEATURE_K6_MTRR (3*32+ 1)
+#define X86_FEATURE_CYRIX_ARR (3*32+ 2)
+#define X86_FEATURE_CENTAUR_MCR (3*32+ 3)
+
+#define X86_FEATURE_K8 (3*32+ 4)
+#define X86_FEATURE_K7 (3*32+ 5)
+#define X86_FEATURE_P3 (3*32+ 6)
+#define X86_FEATURE_P4 (3*32+ 7)
+#define X86_FEATURE_CONSTANT_TSC (3*32+ 8)
+#define X86_FEATURE_UP (3*32+ 9)
+#define X86_FEATURE_FXSAVE_LEAK (3*32+10)
+#define X86_FEATURE_ARCH_PERFMON (3*32+11)
+#define X86_FEATURE_PEBS (3*32+12)
+#define X86_FEATURE_BTS (3*32+13)
+
+#define X86_FEATURE_SYNC_RDTSC (3*32+15)
+#define X86_FEATURE_REP_GOOD (3*32+16)
+
+#define X86_FEATURE_XMM3 (4*32+ 0)
+#define X86_FEATURE_MWAIT (4*32+ 3)
+#define X86_FEATURE_DSCPL (4*32+ 4)
+#define X86_FEATURE_EST (4*32+ 7)
+#define X86_FEATURE_TM2 (4*32+ 8)
+#define X86_FEATURE_CID (4*32+10)
+#define X86_FEATURE_CX16 (4*32+13)
+#define X86_FEATURE_XTPR (4*32+14)
+#define X86_FEATURE_DCA (4*32+18)
+
+#define X86_FEATURE_XSTORE (5*32+ 2)
+#define X86_FEATURE_XSTORE_EN (5*32+ 3)
+#define X86_FEATURE_XCRYPT (5*32+ 6)
+#define X86_FEATURE_XCRYPT_EN (5*32+ 7)
+#define X86_FEATURE_ACE2 (5*32+ 8)
+#define X86_FEATURE_ACE2_EN (5*32+ 9)
+#define X86_FEATURE_PHE (5*32+ 10)
+#define X86_FEATURE_PHE_EN (5*32+ 11)
+#define X86_FEATURE_PMM (5*32+ 12)
+#define X86_FEATURE_PMM_EN (5*32+ 13)
+
+#define X86_FEATURE_LAHF_LM (6*32+ 0)
+#define X86_FEATURE_CMP_LEGACY (6*32+ 1)
+
+#define X86_FEATURE_IDA (7*32+ 0)
+
+#define cpu_has(c, bit) (__builtin_constant_p(bit) && ( (((bit)>>5)==0 && (1UL<<((bit)&31) & REQUIRED_MASK0)) || (((bit)>>5)==1 && (1UL<<((bit)&31) & REQUIRED_MASK1)) || (((bit)>>5)==2 && (1UL<<((bit)&31) & REQUIRED_MASK2)) || (((bit)>>5)==3 && (1UL<<((bit)&31) & REQUIRED_MASK3)) || (((bit)>>5)==4 && (1UL<<((bit)&31) & REQUIRED_MASK4)) || (((bit)>>5)==5 && (1UL<<((bit)&31) & REQUIRED_MASK5)) || (((bit)>>5)==6 && (1UL<<((bit)&31) & REQUIRED_MASK6)) || (((bit)>>5)==7 && (1UL<<((bit)&31) & REQUIRED_MASK7)) ) ? 1 : test_bit(bit, (c)->x86_capability))
+#define boot_cpu_has(bit) cpu_has(&boot_cpu_data, bit)
+
+#define cpu_has_fpu boot_cpu_has(X86_FEATURE_FPU)
+#define cpu_has_vme boot_cpu_has(X86_FEATURE_VME)
+#define cpu_has_de boot_cpu_has(X86_FEATURE_DE)
+#define cpu_has_pse boot_cpu_has(X86_FEATURE_PSE)
+#define cpu_has_tsc boot_cpu_has(X86_FEATURE_TSC)
+#define cpu_has_pae boot_cpu_has(X86_FEATURE_PAE)
+#define cpu_has_pge boot_cpu_has(X86_FEATURE_PGE)
+#define cpu_has_apic boot_cpu_has(X86_FEATURE_APIC)
+#define cpu_has_sep boot_cpu_has(X86_FEATURE_SEP)
+#define cpu_has_mtrr boot_cpu_has(X86_FEATURE_MTRR)
+#define cpu_has_mmx boot_cpu_has(X86_FEATURE_MMX)
+#define cpu_has_fxsr boot_cpu_has(X86_FEATURE_FXSR)
+#define cpu_has_xmm boot_cpu_has(X86_FEATURE_XMM)
+#define cpu_has_xmm2 boot_cpu_has(X86_FEATURE_XMM2)
+#define cpu_has_xmm3 boot_cpu_has(X86_FEATURE_XMM3)
+#define cpu_has_ht boot_cpu_has(X86_FEATURE_HT)
+#define cpu_has_mp boot_cpu_has(X86_FEATURE_MP)
+#define cpu_has_nx boot_cpu_has(X86_FEATURE_NX)
+#define cpu_has_k6_mtrr boot_cpu_has(X86_FEATURE_K6_MTRR)
+#define cpu_has_cyrix_arr boot_cpu_has(X86_FEATURE_CYRIX_ARR)
+#define cpu_has_centaur_mcr boot_cpu_has(X86_FEATURE_CENTAUR_MCR)
+#define cpu_has_xstore boot_cpu_has(X86_FEATURE_XSTORE)
+#define cpu_has_xstore_enabled boot_cpu_has(X86_FEATURE_XSTORE_EN)
+#define cpu_has_xcrypt boot_cpu_has(X86_FEATURE_XCRYPT)
+#define cpu_has_xcrypt_enabled boot_cpu_has(X86_FEATURE_XCRYPT_EN)
+#define cpu_has_ace2 boot_cpu_has(X86_FEATURE_ACE2)
+#define cpu_has_ace2_enabled boot_cpu_has(X86_FEATURE_ACE2_EN)
+#define cpu_has_phe boot_cpu_has(X86_FEATURE_PHE)
+#define cpu_has_phe_enabled boot_cpu_has(X86_FEATURE_PHE_EN)
+#define cpu_has_pmm boot_cpu_has(X86_FEATURE_PMM)
+#define cpu_has_pmm_enabled boot_cpu_has(X86_FEATURE_PMM_EN)
+#define cpu_has_ds boot_cpu_has(X86_FEATURE_DS)
+#define cpu_has_pebs boot_cpu_has(X86_FEATURE_PEBS)
+#define cpu_has_clflush boot_cpu_has(X86_FEATURE_CLFLSH)
+#define cpu_has_bts boot_cpu_has(X86_FEATURE_BTS)
+
+#endif
+
diff --git a/libc/kernel/arch-x86/asm/cputime.h b/libc/kernel/arch-x86/asm/cputime.h
new file mode 100644
index 0000000..0e79e0b
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/cputime.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include <asm-generic/cputime.h>
diff --git a/libc/kernel/arch-x86/asm/current.h b/libc/kernel/arch-x86/asm/current.h
new file mode 100644
index 0000000..b53c6fe
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/current.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "current_64.h"
diff --git a/libc/kernel/arch-x86/asm/current_32.h b/libc/kernel/arch-x86/asm/current_32.h
new file mode 100644
index 0000000..f74b371
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/current_32.h
@@ -0,0 +1,21 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _I386_CURRENT_H
+#define _I386_CURRENT_H
+
+#include <linux/compiler.h>
+#include <asm/percpu.h>
+
+struct task_struct;
+
+#define current get_current()
+#endif
diff --git a/libc/kernel/arch-x86/asm/delay.h b/libc/kernel/arch-x86/asm/delay.h
new file mode 100644
index 0000000..7cb5f74
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/delay.h
@@ -0,0 +1,19 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_DELAY_H
+#define _ASM_X86_DELAY_H
+
+#define udelay(n) (__builtin_constant_p(n) ? ((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c7ul)) : __udelay(n))
+
+#define ndelay(n) (__builtin_constant_p(n) ? ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : __ndelay(n))
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/desc.h b/libc/kernel/arch-x86/asm/desc.h
new file mode 100644
index 0000000..e9d448b
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/desc.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "desc_64.h"
diff --git a/libc/kernel/arch-x86/asm/desc_32.h b/libc/kernel/arch-x86/asm/desc_32.h
new file mode 100644
index 0000000..f53191c
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/desc_32.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ARCH_DESC_H
+#define __ARCH_DESC_H
+
+#include <asm/ldt.h>
+#include <asm/segment.h>
+
+#ifndef __ASSEMBLY__
+
+#include <linux/preempt.h>
+#include <linux/smp.h>
+#include <linux/percpu.h>
+
+#include <asm/mmu.h>
+
+struct Xgt_desc_struct {
+ unsigned short size;
+ unsigned long address __attribute__((packed));
+ unsigned short pad;
+} __attribute__ ((packed));
+
+struct gdt_page
+{
+ struct desc_struct gdt[GDT_ENTRIES];
+} __attribute__((aligned(PAGE_SIZE)));
+
+#define DESCTYPE_LDT 0x82
+#define DESCTYPE_TSS 0x89
+#define DESCTYPE_TASK 0x85
+#define DESCTYPE_INT 0x8e
+#define DESCTYPE_TRAP 0x8f
+#define DESCTYPE_DPL3 0x60
+#define DESCTYPE_S 0x10
+#define load_TR_desc() native_load_tr_desc()
+#define load_gdt(dtr) native_load_gdt(dtr)
+#define load_idt(dtr) native_load_idt(dtr)
+#define load_tr(tr) __asm__ __volatile("ltr %0"::"m" (tr))
+#define load_ldt(ldt) __asm__ __volatile("lldt %0"::"m" (ldt))
+#define store_gdt(dtr) native_store_gdt(dtr)
+#define store_idt(dtr) native_store_idt(dtr)
+#define store_tr(tr) (tr = native_store_tr())
+#define store_ldt(ldt) __asm__ ("sldt %0":"=m" (ldt))
+#define load_TLS(t, cpu) native_load_tls(t, cpu)
+#define set_ldt native_set_ldt
+#define write_ldt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
+#define write_gdt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
+#define write_idt_entry(dt, entry, a, b) write_dt_entry(dt, entry, a, b)
+#define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr)
+#define LDT_entry_a(info) ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff))
+#define LDT_entry_b(info) (((info)->base_addr & 0xff000000) | (((info)->base_addr & 0x00ff0000) >> 16) | ((info)->limit & 0xf0000) | (((info)->read_exec_only ^ 1) << 9) | ((info)->contents << 10) | (((info)->seg_not_present ^ 1) << 15) | ((info)->seg_32bit << 22) | ((info)->limit_in_pages << 23) | ((info)->useable << 20) | 0x7000)
+#define LDT_empty(info) ( (info)->base_addr == 0 && (info)->limit == 0 && (info)->contents == 0 && (info)->read_exec_only == 1 && (info)->seg_32bit == 0 && (info)->limit_in_pages == 0 && (info)->seg_not_present == 1 && (info)->useable == 0 )
+#else
+#define GET_DESC_BASE(idx, gdt, base, lo_w, lo_b, hi_b) movb idx*8+4(gdt), lo_b; movb idx*8+7(gdt), hi_b; shll $16, base; movw idx*8+2(gdt), lo_w;
+#endif
+#endif
diff --git a/libc/kernel/arch-x86/asm/desc_defs.h b/libc/kernel/arch-x86/asm/desc_defs.h
new file mode 100644
index 0000000..bf6de4a
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/desc_defs.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ARCH_DESC_DEFS_H
+#define __ARCH_DESC_DEFS_H
+
+#ifndef __ASSEMBLY__
+
+#include <linux/types.h>
+
+struct desc_struct {
+ u16 limit0;
+ u16 base0;
+ unsigned base1 : 8, type : 4, s : 1, dpl : 2, p : 1;
+ unsigned limit : 4, avl : 1, l : 1, d : 1, g : 1, base2 : 8;
+} __attribute__((packed));
+
+struct n_desc_struct {
+ unsigned int a,b;
+};
+
+enum {
+ GATE_INTERRUPT = 0xE,
+ GATE_TRAP = 0xF,
+ GATE_CALL = 0xC,
+};
+
+struct gate_struct {
+ u16 offset_low;
+ u16 segment;
+ unsigned ist : 3, zero0 : 5, type : 5, dpl : 2, p : 1;
+ u16 offset_middle;
+ u32 offset_high;
+ u32 zero1;
+} __attribute__((packed));
+
+#define PTR_LOW(x) ((unsigned long)(x) & 0xFFFF)
+#define PTR_MIDDLE(x) (((unsigned long)(x) >> 16) & 0xFFFF)
+#define PTR_HIGH(x) ((unsigned long)(x) >> 32)
+
+enum {
+ DESC_TSS = 0x9,
+ DESC_LDT = 0x2,
+};
+
+struct ldttss_desc {
+ u16 limit0;
+ u16 base0;
+ unsigned base1 : 8, type : 5, dpl : 2, p : 1;
+ unsigned limit1 : 4, zero0 : 3, g : 1, base2 : 8;
+ u32 base3;
+ u32 zero1;
+} __attribute__((packed));
+
+struct desc_ptr {
+ unsigned short size;
+ unsigned long address;
+} __attribute__((packed)) ;
+
+#endif
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/div64.h b/libc/kernel/arch-x86/asm/div64.h
new file mode 100644
index 0000000..3fef43e
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/div64.h
@@ -0,0 +1,17 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_DIV64_H
+#define _ASM_X86_DIV64_H
+
+#include <asm-generic/div64.h>
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/dma-mapping.h b/libc/kernel/arch-x86/asm/dma-mapping.h
new file mode 100644
index 0000000..3da1da6
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/dma-mapping.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "dma-mapping_64.h"
diff --git a/libc/kernel/arch-x86/asm/dma-mapping_32.h b/libc/kernel/arch-x86/asm/dma-mapping_32.h
new file mode 100644
index 0000000..974a60b
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/dma-mapping_32.h
@@ -0,0 +1,28 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_I386_DMA_MAPPING_H
+#define _ASM_I386_DMA_MAPPING_H
+
+#include <linux/mm.h>
+#include <linux/scatterlist.h>
+
+#include <asm/cache.h>
+#include <asm/io.h>
+#include <asm/bug.h>
+
+#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
+#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
+
+#define dma_is_consistent(d, h) (1)
+#define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/dma.h b/libc/kernel/arch-x86/asm/dma.h
new file mode 100644
index 0000000..ae51e02
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/dma.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "dma_64.h"
diff --git a/libc/kernel/arch-x86/asm/dma_32.h b/libc/kernel/arch-x86/asm/dma_32.h
new file mode 100644
index 0000000..9c24f5e
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/dma_32.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_DMA_H
+#define _ASM_DMA_H
+
+#include <linux/spinlock.h>
+#include <asm/io.h>
+#include <linux/delay.h>
+
+#ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER
+#define dma_outb outb_p
+#else
+#define dma_outb outb
+#endif
+
+#define dma_inb inb
+
+#define MAX_DMA_CHANNELS 8
+
+#define MAX_DMA_ADDRESS (PAGE_OFFSET+0x1000000)
+
+#define IO_DMA1_BASE 0x00
+#define IO_DMA2_BASE 0xC0
+
+#define DMA1_CMD_REG 0x08
+#define DMA1_STAT_REG 0x08
+#define DMA1_REQ_REG 0x09
+#define DMA1_MASK_REG 0x0A
+#define DMA1_MODE_REG 0x0B
+#define DMA1_CLEAR_FF_REG 0x0C
+#define DMA1_TEMP_REG 0x0D
+#define DMA1_RESET_REG 0x0D
+#define DMA1_CLR_MASK_REG 0x0E
+#define DMA1_MASK_ALL_REG 0x0F
+
+#define DMA2_CMD_REG 0xD0
+#define DMA2_STAT_REG 0xD0
+#define DMA2_REQ_REG 0xD2
+#define DMA2_MASK_REG 0xD4
+#define DMA2_MODE_REG 0xD6
+#define DMA2_CLEAR_FF_REG 0xD8
+#define DMA2_TEMP_REG 0xDA
+#define DMA2_RESET_REG 0xDA
+#define DMA2_CLR_MASK_REG 0xDC
+#define DMA2_MASK_ALL_REG 0xDE
+
+#define DMA_ADDR_0 0x00
+#define DMA_ADDR_1 0x02
+#define DMA_ADDR_2 0x04
+#define DMA_ADDR_3 0x06
+#define DMA_ADDR_4 0xC0
+#define DMA_ADDR_5 0xC4
+#define DMA_ADDR_6 0xC8
+#define DMA_ADDR_7 0xCC
+
+#define DMA_CNT_0 0x01
+#define DMA_CNT_1 0x03
+#define DMA_CNT_2 0x05
+#define DMA_CNT_3 0x07
+#define DMA_CNT_4 0xC2
+#define DMA_CNT_5 0xC6
+#define DMA_CNT_6 0xCA
+#define DMA_CNT_7 0xCE
+
+#define DMA_PAGE_0 0x87
+#define DMA_PAGE_1 0x83
+#define DMA_PAGE_2 0x81
+#define DMA_PAGE_3 0x82
+#define DMA_PAGE_5 0x8B
+#define DMA_PAGE_6 0x89
+#define DMA_PAGE_7 0x8A
+
+#define DMA_MODE_READ 0x44
+#define DMA_MODE_WRITE 0x48
+#define DMA_MODE_CASCADE 0xC0
+
+#define DMA_AUTOINIT 0x10
+
+#define isa_dma_bridge_buggy (0)
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/dwarf2.h b/libc/kernel/arch-x86/asm/dwarf2.h
new file mode 100644
index 0000000..c937591
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/dwarf2.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "dwarf2_64.h"
diff --git a/libc/kernel/arch-x86/asm/dwarf2_32.h b/libc/kernel/arch-x86/asm/dwarf2_32.h
new file mode 100644
index 0000000..a2dc3f1
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/dwarf2_32.h
@@ -0,0 +1,33 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _DWARF2_H
+#define _DWARF2_H
+
+#ifndef __ASSEMBLY__
+#warning "asm/dwarf2.h should be only included in pure assembly files"
+#endif
+
+#define CFI_STARTPROC ignore
+#define CFI_ENDPROC ignore
+#define CFI_DEF_CFA ignore
+#define CFI_DEF_CFA_REGISTER ignore
+#define CFI_DEF_CFA_OFFSET ignore
+#define CFI_ADJUST_CFA_OFFSET ignore
+#define CFI_OFFSET ignore
+#define CFI_REL_OFFSET ignore
+#define CFI_REGISTER ignore
+#define CFI_RESTORE ignore
+#define CFI_REMEMBER_STATE ignore
+#define CFI_RESTORE_STATE ignore
+#define CFI_UNDEFINED ignore
+#define CFI_SIGNAL_FRAME ignore
+#endif
diff --git a/libc/kernel/arch-x86/asm/e820.h b/libc/kernel/arch-x86/asm/e820.h
new file mode 100644
index 0000000..8a88ff0
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/e820.h
@@ -0,0 +1,36 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_E820_H
+#define __ASM_E820_H
+#define E820MAP 0x2d0
+#define E820MAX 128
+#define E820NR 0x1e8
+
+#define E820_RAM 1
+#define E820_RESERVED 2
+#define E820_ACPI 3
+#define E820_NVS 4
+
+#ifndef __ASSEMBLY__
+struct e820entry {
+ __u64 addr;
+ __u64 size;
+ __u32 type;
+} __attribute__((packed));
+
+struct e820map {
+ __u32 nr_map;
+ struct e820entry map[E820MAX];
+};
+#endif
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/elf.h b/libc/kernel/arch-x86/asm/elf.h
new file mode 100644
index 0000000..6c6fbbf
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/elf.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_ELF_H
+#define _ASM_X86_ELF_H
+
+#include <asm/ptrace.h>
+#include <asm/user.h>
+#include <asm/auxvec.h>
+
+typedef unsigned long elf_greg_t;
+
+#define ELF_NGREG (sizeof (struct user_regs_struct) / sizeof(elf_greg_t))
+typedef elf_greg_t elf_gregset_t[ELF_NGREG];
+
+typedef struct user_i387_struct elf_fpregset_t;
+
+#ifdef __i386__
+
+typedef struct user_fxsr_struct elf_fpxregset_t;
+
+#define R_386_NONE 0
+#define R_386_32 1
+#define R_386_PC32 2
+#define R_386_GOT32 3
+#define R_386_PLT32 4
+#define R_386_COPY 5
+#define R_386_GLOB_DAT 6
+#define R_386_JMP_SLOT 7
+#define R_386_RELATIVE 8
+#define R_386_GOTOFF 9
+#define R_386_GOTPC 10
+#define R_386_NUM 11
+
+#define ELF_CLASS ELFCLASS32
+#define ELF_DATA ELFDATA2LSB
+#define ELF_ARCH EM_386
+
+#else
+
+#define R_X86_64_NONE 0
+#define R_X86_64_64 1
+#define R_X86_64_PC32 2
+#define R_X86_64_GOT32 3
+#define R_X86_64_PLT32 4
+#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
+#define R_X86_64_GOTPCREL 9
+#define R_X86_64_32 10
+#define R_X86_64_32S 11
+#define R_X86_64_16 12
+#define R_X86_64_PC16 13
+#define R_X86_64_8 14
+#define R_X86_64_PC8 15
+
+#define R_X86_64_NUM 16
+
+#define ELF_CLASS ELFCLASS64
+#define ELF_DATA ELFDATA2LSB
+#define ELF_ARCH EM_X86_64
+
+#endif
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/errno.h b/libc/kernel/arch-x86/asm/errno.h
new file mode 100644
index 0000000..e8f7425
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/errno.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include <asm-generic/errno.h>
diff --git a/libc/kernel/arch-x86/asm/fcntl.h b/libc/kernel/arch-x86/asm/fcntl.h
new file mode 100644
index 0000000..00630ad
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/fcntl.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include <asm-generic/fcntl.h>
diff --git a/libc/kernel/arch-x86/asm/fixmap.h b/libc/kernel/arch-x86/asm/fixmap.h
new file mode 100644
index 0000000..19b9cc8
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/fixmap.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "fixmap_64.h"
diff --git a/libc/kernel/arch-x86/asm/fixmap_32.h b/libc/kernel/arch-x86/asm/fixmap_32.h
new file mode 100644
index 0000000..95de8a0
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/fixmap_32.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_FIXMAP_H
+#define _ASM_FIXMAP_H
+
+#define FIXADDR_USER_START __fix_to_virt(FIX_VDSO)
+#define FIXADDR_USER_END __fix_to_virt(FIX_VDSO - 1)
+
+#ifndef __ASSEMBLY__
+#include <linux/kernel.h>
+#include <asm/acpi.h>
+#include <asm/apicdef.h>
+#include <asm/page.h>
+
+enum fixed_addresses {
+ FIX_HOLE,
+ FIX_VDSO,
+ FIX_DBGP_BASE,
+ FIX_EARLYCON_MEM_BASE,
+ __end_of_permanent_fixed_addresses,
+
+#define NR_FIX_BTMAPS 16
+ FIX_BTMAP_END = __end_of_permanent_fixed_addresses,
+ FIX_BTMAP_BEGIN = FIX_BTMAP_END + NR_FIX_BTMAPS - 1,
+ FIX_WP_TEST,
+ __end_of_fixed_addresses
+};
+
+#define set_fixmap(idx, phys) __set_fixmap(idx, phys, PAGE_KERNEL)
+
+#define set_fixmap_nocache(idx, phys) __set_fixmap(idx, phys, PAGE_KERNEL_NOCACHE)
+
+#define clear_fixmap(idx) __set_fixmap(idx, 0, __pgprot(0))
+
+#define FIXADDR_TOP ((unsigned long)__FIXADDR_TOP)
+
+#define __FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT)
+#define __FIXADDR_BOOT_SIZE (__end_of_fixed_addresses << PAGE_SHIFT)
+#define FIXADDR_START (FIXADDR_TOP - __FIXADDR_SIZE)
+#define FIXADDR_BOOT_START (FIXADDR_TOP - __FIXADDR_BOOT_SIZE)
+
+#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
+#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)
+
+#endif
+#endif
diff --git a/libc/kernel/arch-x86/asm/genapic.h b/libc/kernel/arch-x86/asm/genapic.h
new file mode 100644
index 0000000..84e687e
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/genapic.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "genapic_64.h"
diff --git a/libc/kernel/arch-x86/asm/genapic_32.h b/libc/kernel/arch-x86/asm/genapic_32.h
new file mode 100644
index 0000000..07801ea
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/genapic_32.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_GENAPIC_H
+#define _ASM_GENAPIC_H 1
+
+#include <asm/mpspec.h>
+
+struct mpc_config_translation;
+struct mpc_config_bus;
+struct mp_config_table;
+struct mpc_config_processor;
+
+struct genapic {
+ char *name;
+ int (*probe)(void);
+
+ int (*apic_id_registered)(void);
+ cpumask_t (*target_cpus)(void);
+ int int_delivery_mode;
+ int int_dest_mode;
+ int ESR_DISABLE;
+ int apic_destination_logical;
+ unsigned long (*check_apicid_used)(physid_mask_t bitmap, int apicid);
+ unsigned long (*check_apicid_present)(int apicid);
+ int no_balance_irq;
+ int no_ioapic_check;
+ void (*init_apic_ldr)(void);
+ physid_mask_t (*ioapic_phys_id_map)(physid_mask_t map);
+
+ void (*setup_apic_routing)(void);
+ int (*multi_timer_check)(int apic, int irq);
+ int (*apicid_to_node)(int logical_apicid);
+ int (*cpu_to_logical_apicid)(int cpu);
+ int (*cpu_present_to_apicid)(int mps_cpu);
+ physid_mask_t (*apicid_to_cpu_present)(int phys_apicid);
+ int (*mpc_apic_id)(struct mpc_config_processor *m,
+ struct mpc_config_translation *t);
+ void (*setup_portio_remap)(void);
+ int (*check_phys_apicid_present)(int boot_cpu_physical_apicid);
+ void (*enable_apic_mode)(void);
+ u32 (*phys_pkg_id)(u32 cpuid_apic, int index_msb);
+
+ void (*mpc_oem_bus_info)(struct mpc_config_bus *, char *,
+ struct mpc_config_translation *);
+ void (*mpc_oem_pci_bus)(struct mpc_config_bus *,
+ struct mpc_config_translation *);
+
+ int (*mps_oem_check)(struct mp_config_table *mpc, char *oem,
+ char *productid);
+ int (*acpi_madt_oem_check)(char *oem_id, char *oem_table_id);
+
+ unsigned (*get_apic_id)(unsigned long x);
+ unsigned long apic_id_mask;
+ unsigned int (*cpu_mask_to_apicid)(cpumask_t cpumask);
+
+};
+
+#define APICFUNC(x) .x = x,
+
+#define IPIFUNC(x)
+
+#define APIC_INIT(aname, aprobe) { .name = aname, .probe = aprobe, .int_delivery_mode = INT_DELIVERY_MODE, .int_dest_mode = INT_DEST_MODE, .no_balance_irq = NO_BALANCE_IRQ, .ESR_DISABLE = esr_disable, .apic_destination_logical = APIC_DEST_LOGICAL, APICFUNC(apic_id_registered) APICFUNC(target_cpus) APICFUNC(check_apicid_used) APICFUNC(check_apicid_present) APICFUNC(init_apic_ldr) APICFUNC(ioapic_phys_id_map) APICFUNC(setup_apic_routing) APICFUNC(multi_timer_check) APICFUNC(apicid_to_node) APICFUNC(cpu_to_logical_apicid) APICFUNC(cpu_present_to_apicid) APICFUNC(apicid_to_cpu_present) APICFUNC(mpc_apic_id) APICFUNC(setup_portio_remap) APICFUNC(check_phys_apicid_present) APICFUNC(mpc_oem_bus_info) APICFUNC(mpc_oem_pci_bus) APICFUNC(mps_oem_check) APICFUNC(get_apic_id) .apic_id_mask = APIC_ID_MASK, APICFUNC(cpu_mask_to_apicid) APICFUNC(acpi_madt_oem_check) IPIFUNC(send_IPI_mask) IPIFUNC(send_IPI_allbutself) IPIFUNC(send_IPI_all) APICFUNC(enable_apic_mode) APICFUNC(phys_pkg_id) }
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/hardirq.h b/libc/kernel/arch-x86/asm/hardirq.h
new file mode 100644
index 0000000..ee224f1
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/hardirq.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "hardirq_64.h"
diff --git a/libc/kernel/arch-x86/asm/hardirq_32.h b/libc/kernel/arch-x86/asm/hardirq_32.h
new file mode 100644
index 0000000..b682f66
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/hardirq_32.h
@@ -0,0 +1,36 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_HARDIRQ_H
+#define __ASM_HARDIRQ_H
+
+#include <linux/threads.h>
+#include <linux/irq.h>
+
+typedef struct {
+ unsigned int __softirq_pending;
+ unsigned long idle_timestamp;
+ unsigned int __nmi_count;
+ unsigned int apic_timer_irqs;
+ unsigned int irq0_irqs;
+ unsigned int irq_resched_count;
+ unsigned int irq_call_count;
+ unsigned int irq_tlb_count;
+ unsigned int irq_thermal_count;
+ unsigned int irq_spurious_count;
+} ____cacheline_aligned irq_cpustat_t;
+
+#define __ARCH_IRQ_STAT
+#define __IRQ_STAT(cpu, member) (per_cpu(irq_stat, cpu).member)
+
+#include <linux/irq_cpustat.h>
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/highmem.h b/libc/kernel/arch-x86/asm/highmem.h
new file mode 100644
index 0000000..f738851
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/highmem.h
@@ -0,0 +1,15 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_HIGHMEM_H
+#define _ASM_HIGHMEM_H
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/hw_irq.h b/libc/kernel/arch-x86/asm/hw_irq.h
new file mode 100644
index 0000000..ed937c7
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/hw_irq.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "hw_irq_64.h"
diff --git a/libc/kernel/arch-x86/asm/hw_irq_32.h b/libc/kernel/arch-x86/asm/hw_irq_32.h
new file mode 100644
index 0000000..6f584fc
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/hw_irq_32.h
@@ -0,0 +1,24 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_HW_IRQ_H
+#define _ASM_HW_IRQ_H
+
+#include <linux/profile.h>
+#include <asm/atomic.h>
+#include <asm/irq.h>
+#include <asm/sections.h>
+
+#define NMI_VECTOR 0x02
+
+#define IO_APIC_IRQ(x) (((x) >= 16) || ((1<<(x)) & io_apic_irqs))
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/i387.h b/libc/kernel/arch-x86/asm/i387.h
new file mode 100644
index 0000000..2692557
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/i387.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "i387_64.h"
diff --git a/libc/kernel/arch-x86/asm/i387_32.h b/libc/kernel/arch-x86/asm/i387_32.h
new file mode 100644
index 0000000..8563fb9
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/i387_32.h
@@ -0,0 +1,33 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_I386_I387_H
+#define __ASM_I386_I387_H
+
+#include <linux/sched.h>
+#include <linux/init.h>
+#include <linux/kernel_stat.h>
+#include <asm/processor.h>
+#include <asm/sigcontext.h>
+#include <asm/user.h>
+
+#define restore_fpu(tsk) alternative_input( "nop ; frstor %1", "fxrstor %1", X86_FEATURE_FXSR, "m" ((tsk)->thread.i387.fxsave))
+
+#define kernel_fpu_end() do { stts(); preempt_enable(); } while(0)
+
+#define safe_address (kstat_cpu(0).cpustat.user)
+
+#define __unlazy_fpu( tsk ) do { if (task_thread_info(tsk)->status & TS_USEDFPU) { __save_init_fpu(tsk); stts(); } else tsk->fpu_counter = 0; } while (0)
+#define __clear_fpu( tsk ) do { if (task_thread_info(tsk)->status & TS_USEDFPU) { asm volatile("fnclex ; fwait"); task_thread_info(tsk)->status &= ~TS_USEDFPU; stts(); } } while (0)
+#define unlazy_fpu( tsk ) do { preempt_disable(); __unlazy_fpu(tsk); preempt_enable(); } while (0)
+#define clear_fpu( tsk ) do { preempt_disable(); __clear_fpu( tsk ); preempt_enable(); } while (0)
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/i8253.h b/libc/kernel/arch-x86/asm/i8253.h
new file mode 100644
index 0000000..93b1d1a
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/i8253.h
@@ -0,0 +1,19 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_I8253_H__
+#define __ASM_I8253_H__
+
+#define PIT_MODE 0x43
+#define PIT_CH0 0x40
+#define PIT_CH2 0x42
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/i8259.h b/libc/kernel/arch-x86/asm/i8259.h
new file mode 100644
index 0000000..c2366ea
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/i8259.h
@@ -0,0 +1,19 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_I8259_H__
+#define __ASM_I8259_H__
+
+#define __byte(x,y) (((unsigned char *) &(y))[x])
+#define cached_master_mask (__byte(0, cached_irq_mask))
+#define cached_slave_mask (__byte(1, cached_irq_mask))
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/ia32_unistd.h b/libc/kernel/arch-x86/asm/ia32_unistd.h
new file mode 100644
index 0000000..848d228
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/ia32_unistd.h
@@ -0,0 +1,22 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_64_IA32_UNISTD_H_
+#define _ASM_X86_64_IA32_UNISTD_H_
+
+#define __NR_ia32_restart_syscall 0
+#define __NR_ia32_exit 1
+#define __NR_ia32_read 3
+#define __NR_ia32_write 4
+#define __NR_ia32_sigreturn 119
+#define __NR_ia32_rt_sigreturn 173
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/io.h b/libc/kernel/arch-x86/asm/io.h
new file mode 100644
index 0000000..ea52e66
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/io.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "io_64.h"
diff --git a/libc/kernel/arch-x86/asm/io_32.h b/libc/kernel/arch-x86/asm/io_32.h
new file mode 100644
index 0000000..f7e0025
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/io_32.h
@@ -0,0 +1,27 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_IO_H
+#define _ASM_IO_H
+
+#include <linux/string.h>
+#include <linux/compiler.h>
+
+#define IO_SPACE_LIMIT 0xffff
+
+#define XQUAD_PORTIO_BASE 0xfe400000
+#define XQUAD_PORTIO_QUAD 0x40000
+
+#ifdef REALLY_SLOW_IO
+#endif
+#define __BUILDIO(bwl,bw,type) static inline void out##bwl(unsigned type value, int port) { out##bwl##_local(value, port); } static inline unsigned type in##bwl(int port) { return in##bwl##_local(port); }
+#define BUILDIO(bwl,bw,type) static inline void out##bwl##_local(unsigned type value, int port) { __asm__ __volatile__("out" #bwl " %" #bw "0, %w1" : : "a"(value), "Nd"(port)); } static inline unsigned type in##bwl##_local(int port) { unsigned type value; __asm__ __volatile__("in" #bwl " %w1, %" #bw "0" : "=a"(value) : "Nd"(port)); return value; } static inline void out##bwl##_local_p(unsigned type value, int port) { out##bwl##_local(value, port); slow_down_io(); } static inline unsigned type in##bwl##_local_p(int port) { unsigned type value = in##bwl##_local(port); slow_down_io(); return value; } __BUILDIO(bwl,bw,type) static inline void out##bwl##_p(unsigned type value, int port) { out##bwl(value, port); slow_down_io(); } static inline unsigned type in##bwl##_p(int port) { unsigned type value = in##bwl(port); slow_down_io(); return value; } static inline void outs##bwl(int port, const void *addr, unsigned long count) { __asm__ __volatile__("rep; outs" #bwl : "+S"(addr), "+c"(count) : "d"(port)); } static inline void ins##bwl(int port, void *addr, unsigned long count) { __asm__ __volatile__("rep; ins" #bwl : "+D"(addr), "+c"(count) : "d"(port)); }
+#endif
diff --git a/libc/kernel/arch-x86/asm/io_apic.h b/libc/kernel/arch-x86/asm/io_apic.h
new file mode 100644
index 0000000..ed608d3
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/io_apic.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "io_apic_64.h"
diff --git a/libc/kernel/arch-x86/asm/io_apic_32.h b/libc/kernel/arch-x86/asm/io_apic_32.h
new file mode 100644
index 0000000..cc858a3
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/io_apic_32.h
@@ -0,0 +1,96 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_IO_APIC_H
+#define __ASM_IO_APIC_H
+
+#include <asm/types.h>
+#include <asm/mpspec.h>
+#include <asm/apicdef.h>
+
+union IO_APIC_reg_00 {
+ u32 raw;
+ struct {
+ u32 __reserved_2 : 14,
+ LTS : 1,
+ delivery_type : 1,
+ __reserved_1 : 8,
+ ID : 8;
+ } __attribute__ ((packed)) bits;
+};
+
+union IO_APIC_reg_01 {
+ u32 raw;
+ struct {
+ u32 version : 8,
+ __reserved_2 : 7,
+ PRQ : 1,
+ entries : 8,
+ __reserved_1 : 8;
+ } __attribute__ ((packed)) bits;
+};
+
+union IO_APIC_reg_02 {
+ u32 raw;
+ struct {
+ u32 __reserved_2 : 24,
+ arbitration : 4,
+ __reserved_1 : 4;
+ } __attribute__ ((packed)) bits;
+};
+
+union IO_APIC_reg_03 {
+ u32 raw;
+ struct {
+ u32 boot_DT : 1,
+ __reserved_1 : 31;
+ } __attribute__ ((packed)) bits;
+};
+
+enum ioapic_irq_destination_types {
+ dest_Fixed = 0,
+ dest_LowestPrio = 1,
+ dest_SMI = 2,
+ dest__reserved_1 = 3,
+ dest_NMI = 4,
+ dest_INIT = 5,
+ dest__reserved_2 = 6,
+ dest_ExtINT = 7
+};
+
+struct IO_APIC_route_entry {
+ __u32 vector : 8,
+ delivery_mode : 3,
+ dest_mode : 1,
+ delivery_status : 1,
+ polarity : 1,
+ irr : 1,
+ trigger : 1,
+ mask : 1,
+ __reserved_2 : 15;
+
+ union { struct { __u32
+ __reserved_1 : 24,
+ physical_dest : 4,
+ __reserved_2 : 4;
+ } physical;
+
+ struct { __u32
+ __reserved_1 : 24,
+ logical_dest : 8;
+ } logical;
+ } dest;
+
+} __attribute__ ((packed));
+
+#define io_apic_assign_pci_irqs 0
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/ioctl.h b/libc/kernel/arch-x86/asm/ioctl.h
new file mode 100644
index 0000000..6e446b6
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/ioctl.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include <asm-generic/ioctl.h>
diff --git a/libc/kernel/arch-x86/asm/ioctls.h b/libc/kernel/arch-x86/asm/ioctls.h
new file mode 100644
index 0000000..3aedc04
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/ioctls.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_IOCTLS_H
+#define _ASM_X86_IOCTLS_H
+
+#include <asm/ioctl.h>
+
+#define TCGETS 0x5401
+#define TCSETS 0x5402
+#define TCSETSW 0x5403
+#define TCSETSF 0x5404
+#define TCGETA 0x5405
+#define TCSETA 0x5406
+#define TCSETAW 0x5407
+#define TCSETAF 0x5408
+#define TCSBRK 0x5409
+#define TCXONC 0x540A
+#define TCFLSH 0x540B
+#define TIOCEXCL 0x540C
+#define TIOCNXCL 0x540D
+#define TIOCSCTTY 0x540E
+#define TIOCGPGRP 0x540F
+#define TIOCSPGRP 0x5410
+#define TIOCOUTQ 0x5411
+#define TIOCSTI 0x5412
+#define TIOCGWINSZ 0x5413
+#define TIOCSWINSZ 0x5414
+#define TIOCMGET 0x5415
+#define TIOCMBIS 0x5416
+#define TIOCMBIC 0x5417
+#define TIOCMSET 0x5418
+#define TIOCGSOFTCAR 0x5419
+#define TIOCSSOFTCAR 0x541A
+#define FIONREAD 0x541B
+#define TIOCINQ FIONREAD
+#define TIOCLINUX 0x541C
+#define TIOCCONS 0x541D
+#define TIOCGSERIAL 0x541E
+#define TIOCSSERIAL 0x541F
+#define TIOCPKT 0x5420
+#define FIONBIO 0x5421
+#define TIOCNOTTY 0x5422
+#define TIOCSETD 0x5423
+#define TIOCGETD 0x5424
+#define TCSBRKP 0x5425
+
+#define TIOCSBRK 0x5427
+#define TIOCCBRK 0x5428
+#define TIOCGSID 0x5429
+#define TCGETS2 _IOR('T',0x2A, struct termios2)
+#define TCSETS2 _IOW('T',0x2B, struct termios2)
+#define TCSETSW2 _IOW('T',0x2C, struct termios2)
+#define TCSETSF2 _IOW('T',0x2D, struct termios2)
+#define TIOCGPTN _IOR('T',0x30, unsigned int)
+#define TIOCSPTLCK _IOW('T',0x31, int)
+
+#define FIONCLEX 0x5450
+#define FIOCLEX 0x5451
+#define FIOASYNC 0x5452
+#define TIOCSERCONFIG 0x5453
+#define TIOCSERGWILD 0x5454
+#define TIOCSERSWILD 0x5455
+#define TIOCGLCKTRMIOS 0x5456
+#define TIOCSLCKTRMIOS 0x5457
+#define TIOCSERGSTRUCT 0x5458
+#define TIOCSERGETLSR 0x5459
+#define TIOCSERGETMULTI 0x545A
+#define TIOCSERSETMULTI 0x545B
+
+#define TIOCMIWAIT 0x545C
+#define TIOCGICOUNT 0x545D
+#define TIOCGHAYESESP 0x545E
+#define TIOCSHAYESESP 0x545F
+#define FIOQSIZE 0x5460
+
+#define TIOCPKT_DATA 0
+#define TIOCPKT_FLUSHREAD 1
+#define TIOCPKT_FLUSHWRITE 2
+#define TIOCPKT_STOP 4
+#define TIOCPKT_START 8
+#define TIOCPKT_NOSTOP 16
+#define TIOCPKT_DOSTOP 32
+
+#define TIOCSER_TEMT 0x01
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/ipcbuf.h b/libc/kernel/arch-x86/asm/ipcbuf.h
new file mode 100644
index 0000000..32342c1
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/ipcbuf.h
@@ -0,0 +1,30 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_IPCBUF_H
+#define _ASM_X86_IPCBUF_H
+
+struct ipc64_perm
+{
+ __kernel_key_t key;
+ __kernel_uid32_t uid;
+ __kernel_gid32_t gid;
+ __kernel_uid32_t cuid;
+ __kernel_gid32_t cgid;
+ __kernel_mode_t mode;
+ unsigned short __pad1;
+ unsigned short seq;
+ unsigned short __pad2;
+ unsigned long __unused1;
+ unsigned long __unused2;
+};
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/irq.h b/libc/kernel/arch-x86/asm/irq.h
new file mode 100644
index 0000000..07a331d
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/irq.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "irq_64.h"
diff --git a/libc/kernel/arch-x86/asm/irq_32.h b/libc/kernel/arch-x86/asm/irq_32.h
new file mode 100644
index 0000000..3141071
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/irq_32.h
@@ -0,0 +1,23 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_IRQ_H
+#define _ASM_IRQ_H
+
+#include <linux/sched.h>
+
+#include "irq_vectors.h"
+#include <asm/thread_info.h>
+
+#define irq_ctx_init(cpu) do { } while (0)
+#define irq_ctx_exit(cpu) do { } while (0)
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/irqflags.h b/libc/kernel/arch-x86/asm/irqflags.h
new file mode 100644
index 0000000..4f84662
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/irqflags.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "irqflags_64.h"
diff --git a/libc/kernel/arch-x86/asm/irqflags_32.h b/libc/kernel/arch-x86/asm/irqflags_32.h
new file mode 100644
index 0000000..9002e44
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/irqflags_32.h
@@ -0,0 +1,33 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_IRQFLAGS_H
+#define _ASM_IRQFLAGS_H
+#include <asm/processor-flags.h>
+
+#ifndef __ASSEMBLY__
+#endif
+#ifndef __ASSEMBLY__
+#else
+#define DISABLE_INTERRUPTS(clobbers) cli
+#define ENABLE_INTERRUPTS(clobbers) sti
+#define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
+#define INTERRUPT_RETURN iret
+#define GET_CR0_INTO_EAX movl %cr0, %eax
+#endif
+#ifndef __ASSEMBLY__
+#define raw_local_save_flags(flags) do { (flags) = __raw_local_save_flags(); } while (0)
+#define raw_local_irq_save(flags) do { (flags) = __raw_local_irq_save(); } while (0)
+#endif
+#define TRACE_IRQS_ON
+#define TRACE_IRQS_OFF
+#define LOCKDEP_SYS_EXIT
+#endif
diff --git a/libc/kernel/arch-x86/asm/ist.h b/libc/kernel/arch-x86/asm/ist.h
new file mode 100644
index 0000000..0abab19
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/ist.h
@@ -0,0 +1,24 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_IST_H
+#define _ASM_IST_H
+
+#include <linux/types.h>
+
+struct ist_info {
+ __u32 signature;
+ __u32 command;
+ __u32 event;
+ __u32 perf_level;
+};
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/kmap_types.h b/libc/kernel/arch-x86/asm/kmap_types.h
new file mode 100644
index 0000000..c2313ee
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/kmap_types.h
@@ -0,0 +1,36 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_KMAP_TYPES_H
+#define _ASM_X86_KMAP_TYPES_H
+
+#define D(n)
+
+enum km_type {
+D(0) KM_BOUNCE_READ,
+D(1) KM_SKB_SUNRPC_DATA,
+D(2) KM_SKB_DATA_SOFTIRQ,
+D(3) KM_USER0,
+D(4) KM_USER1,
+D(5) KM_BIO_SRC_IRQ,
+D(6) KM_BIO_DST_IRQ,
+D(7) KM_PTE0,
+D(8) KM_PTE1,
+D(9) KM_IRQ0,
+D(10) KM_IRQ1,
+D(11) KM_SOFTIRQ0,
+D(12) KM_SOFTIRQ1,
+D(13) KM_TYPE_NR
+};
+
+#undef D
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/ldt.h b/libc/kernel/arch-x86/asm/ldt.h
new file mode 100644
index 0000000..19b91ab
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/ldt.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_LDT_H
+#define _ASM_X86_LDT_H
+
+#define LDT_ENTRIES 8192
+
+#define LDT_ENTRY_SIZE 8
+
+#ifndef __ASSEMBLY__
+
+struct user_desc {
+ unsigned int entry_number;
+ unsigned int base_addr;
+ unsigned int limit;
+ unsigned int seg_32bit:1;
+ unsigned int contents:2;
+ unsigned int read_exec_only:1;
+ unsigned int limit_in_pages:1;
+ unsigned int seg_not_present:1;
+ unsigned int useable:1;
+#ifdef __x86_64__
+ unsigned int lm:1;
+#endif
+};
+
+#define MODIFY_LDT_CONTENTS_DATA 0
+#define MODIFY_LDT_CONTENTS_STACK 1
+#define MODIFY_LDT_CONTENTS_CODE 2
+
+#endif
+#endif
diff --git a/libc/kernel/arch-x86/asm/linkage.h b/libc/kernel/arch-x86/asm/linkage.h
new file mode 100644
index 0000000..f149e4d
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/linkage.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "linkage_64.h"
diff --git a/libc/kernel/arch-x86/asm/linkage_32.h b/libc/kernel/arch-x86/asm/linkage_32.h
new file mode 100644
index 0000000..6db10ee
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/linkage_32.h
@@ -0,0 +1,21 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_LINKAGE_H
+#define __ASM_LINKAGE_H
+
+#define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0)))
+#define FASTCALL(x) x __attribute__((regparm(3)))
+#define fastcall __attribute__((regparm(3)))
+
+#define prevent_tail_call(ret) __asm__ ("" : "=r" (ret) : "0" (ret))
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/local.h b/libc/kernel/arch-x86/asm/local.h
new file mode 100644
index 0000000..85080b8
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/local.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "local_64.h"
diff --git a/libc/kernel/arch-x86/asm/local_32.h b/libc/kernel/arch-x86/asm/local_32.h
new file mode 100644
index 0000000..fcad753
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/local_32.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ARCH_I386_LOCAL_H
+#define _ARCH_I386_LOCAL_H
+
+#include <linux/percpu.h>
+#include <asm/system.h>
+#include <asm/atomic.h>
+
+typedef struct
+{
+ atomic_long_t a;
+} local_t;
+
+#define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
+
+#define local_read(l) atomic_long_read(&(l)->a)
+#define local_set(l,i) atomic_long_set(&(l)->a, (i))
+
+#define local_inc_return(l) (local_add_return(1,l))
+#define local_dec_return(l) (local_sub_return(1,l))
+#define local_cmpxchg(l, o, n) (cmpxchg_local(&((l)->a.counter), (o), (n)))
+#define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
+#define local_add_unless(l, a, u) ({ long c, old; c = local_read(l); for (;;) { if (unlikely(c == (u))) break; old = local_cmpxchg((l), c, c + (a)); if (likely(old == c)) break; c = old; } c != (u); })
+#define local_inc_not_zero(l) local_add_unless((l), 1, 0)
+#define __local_inc(l) local_inc(l)
+#define __local_dec(l) local_dec(l)
+#define __local_add(i,l) local_add((i),(l))
+#define __local_sub(i,l) local_sub((i),(l))
+#define cpu_local_wrap_v(l) ({ local_t res__; preempt_disable(); res__ = (l); preempt_enable(); res__; })
+#define cpu_local_wrap(l) ({ preempt_disable(); l; preempt_enable(); })
+#define cpu_local_read(l) cpu_local_wrap_v(local_read(&__get_cpu_var(l)))
+#define cpu_local_set(l, i) cpu_local_wrap(local_set(&__get_cpu_var(l), (i)))
+#define cpu_local_inc(l) cpu_local_wrap(local_inc(&__get_cpu_var(l)))
+#define cpu_local_dec(l) cpu_local_wrap(local_dec(&__get_cpu_var(l)))
+#define cpu_local_add(i, l) cpu_local_wrap(local_add((i), &__get_cpu_var(l)))
+#define cpu_local_sub(i, l) cpu_local_wrap(local_sub((i), &__get_cpu_var(l)))
+#define __cpu_local_inc(l) cpu_local_inc(l)
+#define __cpu_local_dec(l) cpu_local_dec(l)
+#define __cpu_local_add(i, l) cpu_local_add((i), (l))
+#define __cpu_local_sub(i, l) cpu_local_sub((i), (l))
+#endif
diff --git a/libc/kernel/arch-x86/asm/math_emu.h b/libc/kernel/arch-x86/asm/math_emu.h
new file mode 100644
index 0000000..9380d19
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/math_emu.h
@@ -0,0 +1,40 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _I386_MATH_EMU_H
+#define _I386_MATH_EMU_H
+
+#include <asm/sigcontext.h>
+
+struct info {
+ long ___orig_eip;
+ long ___ebx;
+ long ___ecx;
+ long ___edx;
+ long ___esi;
+ long ___edi;
+ long ___ebp;
+ long ___eax;
+ long ___ds;
+ long ___es;
+ long ___fs;
+ long ___orig_eax;
+ long ___eip;
+ long ___cs;
+ long ___eflags;
+ long ___esp;
+ long ___ss;
+ long ___vm86_es;
+ long ___vm86_ds;
+ long ___vm86_fs;
+ long ___vm86_gs;
+};
+#endif
diff --git a/libc/kernel/arch-x86/asm/mc146818rtc.h b/libc/kernel/arch-x86/asm/mc146818rtc.h
new file mode 100644
index 0000000..8497877
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/mc146818rtc.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "mc146818rtc_64.h"
diff --git a/libc/kernel/arch-x86/asm/mc146818rtc_32.h b/libc/kernel/arch-x86/asm/mc146818rtc_32.h
new file mode 100644
index 0000000..899d608
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/mc146818rtc_32.h
@@ -0,0 +1,44 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_MC146818RTC_H
+#define _ASM_MC146818RTC_H
+
+#include <asm/io.h>
+#include <asm/system.h>
+#include <asm/processor.h>
+#include <linux/mc146818rtc.h>
+
+#ifndef RTC_PORT
+#define RTC_PORT(x) (0x70 + (x))
+#define RTC_ALWAYS_BCD 1
+#endif
+
+#ifdef __HAVE_ARCH_CMPXCHG
+
+#include <linux/smp.h>
+
+#define lock_cmos_prefix(reg) do { unsigned long cmos_flags; local_irq_save(cmos_flags); lock_cmos(reg)
+#define lock_cmos_suffix(reg) unlock_cmos(); local_irq_restore(cmos_flags); } while (0)
+#else
+#define lock_cmos_prefix(reg) do {} while (0)
+#define lock_cmos_suffix(reg) do {} while (0)
+#define lock_cmos(reg)
+#define unlock_cmos()
+#define do_i_have_lock_cmos() 0
+#define current_lock_cmos_reg() 0
+#endif
+#define CMOS_READ(addr) rtc_cmos_read(addr)
+#define CMOS_WRITE(val, addr) rtc_cmos_write(val, addr)
+
+#define RTC_IRQ 8
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/mman.h b/libc/kernel/arch-x86/asm/mman.h
new file mode 100644
index 0000000..7eda319
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/mman.h
@@ -0,0 +1,30 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_MMAN_H
+#define _ASM_X86_MMAN_H
+
+#include <asm-generic/mman.h>
+
+#define MAP_32BIT 0x40
+
+#define MAP_GROWSDOWN 0x0100
+#define MAP_DENYWRITE 0x0800
+#define MAP_EXECUTABLE 0x1000
+#define MAP_LOCKED 0x2000
+#define MAP_NORESERVE 0x4000
+#define MAP_POPULATE 0x8000
+#define MAP_NONBLOCK 0x10000
+
+#define MCL_CURRENT 1
+#define MCL_FUTURE 2
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/mmsegment.h b/libc/kernel/arch-x86/asm/mmsegment.h
new file mode 100644
index 0000000..76045c7
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/mmsegment.h
@@ -0,0 +1,19 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_MMSEGMENT_H
+#define _ASM_MMSEGMENT_H 1
+
+typedef struct {
+ unsigned long seg;
+} mm_segment_t;
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/mmu.h b/libc/kernel/arch-x86/asm/mmu.h
new file mode 100644
index 0000000..30db10a
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/mmu.h
@@ -0,0 +1,25 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_MMU_H
+#define _ASM_X86_MMU_H
+
+#include <linux/spinlock.h>
+#include <linux/mutex.h>
+
+typedef struct {
+ void *ldt;
+ int size;
+ struct mutex lock;
+ void *vdso;
+} mm_context_t;
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/module.h b/libc/kernel/arch-x86/asm/module.h
new file mode 100644
index 0000000..ff292d4
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/module.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "module_64.h"
diff --git a/libc/kernel/arch-x86/asm/module_32.h b/libc/kernel/arch-x86/asm/module_32.h
new file mode 100644
index 0000000..2e26729
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/module_32.h
@@ -0,0 +1,29 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_I386_MODULE_H
+#define _ASM_I386_MODULE_H
+
+struct mod_arch_specific
+{
+};
+
+#define Elf_Shdr Elf32_Shdr
+#define Elf_Sym Elf32_Sym
+#define Elf_Ehdr Elf32_Ehdr
+
+#error unknown processor family
+
+#define MODULE_STACKSIZE ""
+
+#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_STACKSIZE
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/mpspec.h b/libc/kernel/arch-x86/asm/mpspec.h
new file mode 100644
index 0000000..2336504
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/mpspec.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "mpspec_64.h"
diff --git a/libc/kernel/arch-x86/asm/mpspec_32.h b/libc/kernel/arch-x86/asm/mpspec_32.h
new file mode 100644
index 0000000..7acbe8a
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/mpspec_32.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_MPSPEC_H
+#define __ASM_MPSPEC_H
+
+#include <linux/cpumask.h>
+#include <asm/mpspec_def.h>
+#include <mach_mpspec.h>
+
+#define PHYSID_ARRAY_SIZE BITS_TO_LONGS(MAX_APICS)
+
+struct physid_mask
+{
+ unsigned long mask[PHYSID_ARRAY_SIZE];
+};
+
+typedef struct physid_mask physid_mask_t;
+
+#define physid_set(physid, map) set_bit(physid, (map).mask)
+#define physid_clear(physid, map) clear_bit(physid, (map).mask)
+#define physid_isset(physid, map) test_bit(physid, (map).mask)
+#define physid_test_and_set(physid, map) test_and_set_bit(physid, (map).mask)
+
+#define physids_and(dst, src1, src2) bitmap_and((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
+#define physids_or(dst, src1, src2) bitmap_or((dst).mask, (src1).mask, (src2).mask, MAX_APICS)
+#define physids_clear(map) bitmap_zero((map).mask, MAX_APICS)
+#define physids_complement(dst, src) bitmap_complement((dst).mask,(src).mask, MAX_APICS)
+#define physids_empty(map) bitmap_empty((map).mask, MAX_APICS)
+#define physids_equal(map1, map2) bitmap_equal((map1).mask, (map2).mask, MAX_APICS)
+#define physids_weight(map) bitmap_weight((map).mask, MAX_APICS)
+#define physids_shift_right(d, s, n) bitmap_shift_right((d).mask, (s).mask, n, MAX_APICS)
+#define physids_shift_left(d, s, n) bitmap_shift_left((d).mask, (s).mask, n, MAX_APICS)
+#define physids_coerce(map) ((map).mask[0])
+
+#define physids_promote(physids) ({ physid_mask_t __physid_mask = PHYSID_MASK_NONE; __physid_mask.mask[0] = physids; __physid_mask; })
+
+#define physid_mask_of_physid(physid) ({ physid_mask_t __physid_mask = PHYSID_MASK_NONE; physid_set(physid, __physid_mask); __physid_mask; })
+
+#define PHYSID_MASK_ALL { {[0 ... PHYSID_ARRAY_SIZE-1] = ~0UL} }
+#define PHYSID_MASK_NONE { {[0 ... PHYSID_ARRAY_SIZE-1] = 0UL} }
+
+#endif
+
diff --git a/libc/kernel/arch-x86/asm/mpspec_def.h b/libc/kernel/arch-x86/asm/mpspec_def.h
new file mode 100644
index 0000000..1f15363
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/mpspec_def.h
@@ -0,0 +1,171 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_MPSPEC_DEF_H
+#define __ASM_MPSPEC_DEF_H
+
+#define SMP_MAGIC_IDENT (('_'<<24)|('P'<<16)|('M'<<8)|'_')
+
+#define MAX_MPC_ENTRY 1024
+#define MAX_APICS 256
+
+struct intel_mp_floating
+{
+ char mpf_signature[4];
+ unsigned long mpf_physptr;
+ unsigned char mpf_length;
+ unsigned char mpf_specification;
+ unsigned char mpf_checksum;
+ unsigned char mpf_feature1;
+ unsigned char mpf_feature2;
+ unsigned char mpf_feature3;
+ unsigned char mpf_feature4;
+ unsigned char mpf_feature5;
+};
+
+struct mp_config_table
+{
+ char mpc_signature[4];
+#define MPC_SIGNATURE "PCMP"
+ unsigned short mpc_length;
+ char mpc_spec;
+ char mpc_checksum;
+ char mpc_oem[8];
+ char mpc_productid[12];
+ unsigned long mpc_oemptr;
+ unsigned short mpc_oemsize;
+ unsigned short mpc_oemcount;
+ unsigned long mpc_lapic;
+ unsigned long reserved;
+};
+
+#define MP_PROCESSOR 0
+#define MP_BUS 1
+#define MP_IOAPIC 2
+#define MP_INTSRC 3
+#define MP_LINTSRC 4
+#define MP_TRANSLATION 192
+
+struct mpc_config_processor
+{
+ unsigned char mpc_type;
+ unsigned char mpc_apicid;
+ unsigned char mpc_apicver;
+ unsigned char mpc_cpuflag;
+#define CPU_ENABLED 1
+#define CPU_BOOTPROCESSOR 2
+ unsigned long mpc_cpufeature;
+#define CPU_STEPPING_MASK 0x0F
+#define CPU_MODEL_MASK 0xF0
+#define CPU_FAMILY_MASK 0xF00
+ unsigned long mpc_featureflag;
+ unsigned long mpc_reserved[2];
+};
+
+struct mpc_config_bus
+{
+ unsigned char mpc_type;
+ unsigned char mpc_busid;
+ unsigned char mpc_bustype[6];
+};
+
+#define BUSTYPE_EISA "EISA"
+#define BUSTYPE_ISA "ISA"
+#define BUSTYPE_INTERN "INTERN"
+#define BUSTYPE_MCA "MCA"
+#define BUSTYPE_VL "VL"
+#define BUSTYPE_PCI "PCI"
+#define BUSTYPE_PCMCIA "PCMCIA"
+#define BUSTYPE_CBUS "CBUS"
+#define BUSTYPE_CBUSII "CBUSII"
+#define BUSTYPE_FUTURE "FUTURE"
+#define BUSTYPE_MBI "MBI"
+#define BUSTYPE_MBII "MBII"
+#define BUSTYPE_MPI "MPI"
+#define BUSTYPE_MPSA "MPSA"
+#define BUSTYPE_NUBUS "NUBUS"
+#define BUSTYPE_TC "TC"
+#define BUSTYPE_VME "VME"
+#define BUSTYPE_XPRESS "XPRESS"
+
+struct mpc_config_ioapic
+{
+ unsigned char mpc_type;
+ unsigned char mpc_apicid;
+ unsigned char mpc_apicver;
+ unsigned char mpc_flags;
+#define MPC_APIC_USABLE 0x01
+ unsigned long mpc_apicaddr;
+};
+
+struct mpc_config_intsrc
+{
+ unsigned char mpc_type;
+ unsigned char mpc_irqtype;
+ unsigned short mpc_irqflag;
+ unsigned char mpc_srcbus;
+ unsigned char mpc_srcbusirq;
+ unsigned char mpc_dstapic;
+ unsigned char mpc_dstirq;
+};
+
+enum mp_irq_source_types {
+ mp_INT = 0,
+ mp_NMI = 1,
+ mp_SMI = 2,
+ mp_ExtINT = 3
+};
+
+#define MP_IRQDIR_DEFAULT 0
+#define MP_IRQDIR_HIGH 1
+#define MP_IRQDIR_LOW 3
+
+struct mpc_config_lintsrc
+{
+ unsigned char mpc_type;
+ unsigned char mpc_irqtype;
+ unsigned short mpc_irqflag;
+ unsigned char mpc_srcbusid;
+ unsigned char mpc_srcbusirq;
+ unsigned char mpc_destapic;
+#define MP_APIC_ALL 0xFF
+ unsigned char mpc_destapiclint;
+};
+
+struct mp_config_oemtable
+{
+ char oem_signature[4];
+#define MPC_OEM_SIGNATURE "_OEM"
+ unsigned short oem_length;
+ char oem_rev;
+ char oem_checksum;
+ char mpc_oem[8];
+};
+
+struct mpc_config_translation
+{
+ unsigned char mpc_type;
+ unsigned char trans_len;
+ unsigned char trans_type;
+ unsigned char trans_quad;
+ unsigned char trans_global;
+ unsigned char trans_local;
+ unsigned short trans_reserved;
+};
+
+enum mp_bustype {
+ MP_BUS_ISA = 1,
+ MP_BUS_EISA,
+ MP_BUS_PCI,
+ MP_BUS_MCA,
+};
+#endif
+
diff --git a/libc/kernel/arch-x86/asm/msgbuf.h b/libc/kernel/arch-x86/asm/msgbuf.h
new file mode 100644
index 0000000..8843e78
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/msgbuf.h
@@ -0,0 +1,38 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_MSGBUF_H
+#define _ASM_X86_MSGBUF_H
+
+struct msqid64_ds {
+ struct ipc64_perm msg_perm;
+ __kernel_time_t msg_stime;
+#ifdef __i386__
+ unsigned long __unused1;
+#endif
+ __kernel_time_t msg_rtime;
+#ifdef __i386__
+ unsigned long __unused2;
+#endif
+ __kernel_time_t msg_ctime;
+#ifdef __i386__
+ unsigned long __unused3;
+#endif
+ unsigned long msg_cbytes;
+ unsigned long msg_qnum;
+ unsigned long msg_qbytes;
+ __kernel_pid_t msg_lspid;
+ __kernel_pid_t msg_lrpid;
+ unsigned long __unused4;
+ unsigned long __unused5;
+};
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/msr-index.h b/libc/kernel/arch-x86/asm/msr-index.h
new file mode 100644
index 0000000..8ea204e
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/msr-index.h
@@ -0,0 +1,283 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_MSR_INDEX_H
+#define __ASM_MSR_INDEX_H
+
+#define MSR_EFER 0xc0000080
+#define MSR_STAR 0xc0000081
+#define MSR_LSTAR 0xc0000082
+#define MSR_CSTAR 0xc0000083
+#define MSR_SYSCALL_MASK 0xc0000084
+#define MSR_FS_BASE 0xc0000100
+#define MSR_GS_BASE 0xc0000101
+#define MSR_KERNEL_GS_BASE 0xc0000102
+
+#define _EFER_SCE 0
+#define _EFER_LME 8
+#define _EFER_LMA 10
+#define _EFER_NX 11
+
+#define EFER_SCE (1<<_EFER_SCE)
+#define EFER_LME (1<<_EFER_LME)
+#define EFER_LMA (1<<_EFER_LMA)
+#define EFER_NX (1<<_EFER_NX)
+
+#define MSR_IA32_PERFCTR0 0x000000c1
+#define MSR_IA32_PERFCTR1 0x000000c2
+#define MSR_FSB_FREQ 0x000000cd
+
+#define MSR_MTRRcap 0x000000fe
+#define MSR_IA32_BBL_CR_CTL 0x00000119
+
+#define MSR_IA32_SYSENTER_CS 0x00000174
+#define MSR_IA32_SYSENTER_ESP 0x00000175
+#define MSR_IA32_SYSENTER_EIP 0x00000176
+
+#define MSR_IA32_MCG_CAP 0x00000179
+#define MSR_IA32_MCG_STATUS 0x0000017a
+#define MSR_IA32_MCG_CTL 0x0000017b
+
+#define MSR_IA32_PEBS_ENABLE 0x000003f1
+#define MSR_IA32_DS_AREA 0x00000600
+#define MSR_IA32_PERF_CAPABILITIES 0x00000345
+
+#define MSR_MTRRfix64K_00000 0x00000250
+#define MSR_MTRRfix16K_80000 0x00000258
+#define MSR_MTRRfix16K_A0000 0x00000259
+#define MSR_MTRRfix4K_C0000 0x00000268
+#define MSR_MTRRfix4K_C8000 0x00000269
+#define MSR_MTRRfix4K_D0000 0x0000026a
+#define MSR_MTRRfix4K_D8000 0x0000026b
+#define MSR_MTRRfix4K_E0000 0x0000026c
+#define MSR_MTRRfix4K_E8000 0x0000026d
+#define MSR_MTRRfix4K_F0000 0x0000026e
+#define MSR_MTRRfix4K_F8000 0x0000026f
+#define MSR_MTRRdefType 0x000002ff
+
+#define MSR_IA32_DEBUGCTLMSR 0x000001d9
+#define MSR_IA32_LASTBRANCHFROMIP 0x000001db
+#define MSR_IA32_LASTBRANCHTOIP 0x000001dc
+#define MSR_IA32_LASTINTFROMIP 0x000001dd
+#define MSR_IA32_LASTINTTOIP 0x000001de
+
+#define MSR_IA32_MC0_CTL 0x00000400
+#define MSR_IA32_MC0_STATUS 0x00000401
+#define MSR_IA32_MC0_ADDR 0x00000402
+#define MSR_IA32_MC0_MISC 0x00000403
+
+#define MSR_P6_PERFCTR0 0x000000c1
+#define MSR_P6_PERFCTR1 0x000000c2
+#define MSR_P6_EVNTSEL0 0x00000186
+#define MSR_P6_EVNTSEL1 0x00000187
+
+#define MSR_AMD64_IBSFETCHCTL 0xc0011030
+#define MSR_AMD64_IBSFETCHLINAD 0xc0011031
+#define MSR_AMD64_IBSFETCHPHYSAD 0xc0011032
+#define MSR_AMD64_IBSOPCTL 0xc0011033
+#define MSR_AMD64_IBSOPRIP 0xc0011034
+#define MSR_AMD64_IBSOPDATA 0xc0011035
+#define MSR_AMD64_IBSOPDATA2 0xc0011036
+#define MSR_AMD64_IBSOPDATA3 0xc0011037
+#define MSR_AMD64_IBSDCLINAD 0xc0011038
+#define MSR_AMD64_IBSDCPHYSAD 0xc0011039
+#define MSR_AMD64_IBSCTL 0xc001103a
+
+#define MSR_K8_TOP_MEM1 0xc001001a
+#define MSR_K8_TOP_MEM2 0xc001001d
+#define MSR_K8_SYSCFG 0xc0010010
+#define MSR_K8_HWCR 0xc0010015
+#define MSR_K8_ENABLE_C1E 0xc0010055
+#define K8_MTRRFIXRANGE_DRAM_ENABLE 0x00040000
+#define K8_MTRRFIXRANGE_DRAM_MODIFY 0x00080000
+#define K8_MTRR_RDMEM_WRMEM_MASK 0x18181818
+
+#define MSR_K7_EVNTSEL0 0xc0010000
+#define MSR_K7_PERFCTR0 0xc0010004
+#define MSR_K7_EVNTSEL1 0xc0010001
+#define MSR_K7_PERFCTR1 0xc0010005
+#define MSR_K7_EVNTSEL2 0xc0010002
+#define MSR_K7_PERFCTR2 0xc0010006
+#define MSR_K7_EVNTSEL3 0xc0010003
+#define MSR_K7_PERFCTR3 0xc0010007
+#define MSR_K7_CLK_CTL 0xc001001b
+#define MSR_K7_HWCR 0xc0010015
+#define MSR_K7_FID_VID_CTL 0xc0010041
+#define MSR_K7_FID_VID_STATUS 0xc0010042
+
+#define MSR_K6_EFER 0xc0000080
+#define MSR_K6_STAR 0xc0000081
+#define MSR_K6_WHCR 0xc0000082
+#define MSR_K6_UWCCR 0xc0000085
+#define MSR_K6_EPMR 0xc0000086
+#define MSR_K6_PSOR 0xc0000087
+#define MSR_K6_PFIR 0xc0000088
+
+#define MSR_IDT_FCR1 0x00000107
+#define MSR_IDT_FCR2 0x00000108
+#define MSR_IDT_FCR3 0x00000109
+#define MSR_IDT_FCR4 0x0000010a
+
+#define MSR_IDT_MCR0 0x00000110
+#define MSR_IDT_MCR1 0x00000111
+#define MSR_IDT_MCR2 0x00000112
+#define MSR_IDT_MCR3 0x00000113
+#define MSR_IDT_MCR4 0x00000114
+#define MSR_IDT_MCR5 0x00000115
+#define MSR_IDT_MCR6 0x00000116
+#define MSR_IDT_MCR7 0x00000117
+#define MSR_IDT_MCR_CTRL 0x00000120
+
+#define MSR_VIA_FCR 0x00001107
+#define MSR_VIA_LONGHAUL 0x0000110a
+#define MSR_VIA_RNG 0x0000110b
+#define MSR_VIA_BCR2 0x00001147
+
+#define MSR_TMTA_LONGRUN_CTRL 0x80868010
+#define MSR_TMTA_LONGRUN_FLAGS 0x80868011
+#define MSR_TMTA_LRTI_READOUT 0x80868018
+#define MSR_TMTA_LRTI_VOLT_MHZ 0x8086801a
+
+#define MSR_IA32_P5_MC_ADDR 0x00000000
+#define MSR_IA32_P5_MC_TYPE 0x00000001
+#define MSR_IA32_TSC 0x00000010
+#define MSR_IA32_PLATFORM_ID 0x00000017
+#define MSR_IA32_EBL_CR_POWERON 0x0000002a
+
+#define MSR_IA32_APICBASE 0x0000001b
+#define MSR_IA32_APICBASE_BSP (1<<8)
+#define MSR_IA32_APICBASE_ENABLE (1<<11)
+#define MSR_IA32_APICBASE_BASE (0xfffff<<12)
+
+#define MSR_IA32_UCODE_WRITE 0x00000079
+#define MSR_IA32_UCODE_REV 0x0000008b
+
+#define MSR_IA32_PERF_STATUS 0x00000198
+#define MSR_IA32_PERF_CTL 0x00000199
+
+#define MSR_IA32_MPERF 0x000000e7
+#define MSR_IA32_APERF 0x000000e8
+
+#define MSR_IA32_THERM_CONTROL 0x0000019a
+#define MSR_IA32_THERM_INTERRUPT 0x0000019b
+#define MSR_IA32_THERM_STATUS 0x0000019c
+#define MSR_IA32_MISC_ENABLE 0x000001a0
+
+#define MSR_P6_EVNTSEL0 0x00000186
+#define MSR_P6_EVNTSEL1 0x00000187
+
+#define MSR_IA32_MCG_EAX 0x00000180
+#define MSR_IA32_MCG_EBX 0x00000181
+#define MSR_IA32_MCG_ECX 0x00000182
+#define MSR_IA32_MCG_EDX 0x00000183
+#define MSR_IA32_MCG_ESI 0x00000184
+#define MSR_IA32_MCG_EDI 0x00000185
+#define MSR_IA32_MCG_EBP 0x00000186
+#define MSR_IA32_MCG_ESP 0x00000187
+#define MSR_IA32_MCG_EFLAGS 0x00000188
+#define MSR_IA32_MCG_EIP 0x00000189
+#define MSR_IA32_MCG_RESERVED 0x0000018a
+
+#define MSR_P4_BPU_PERFCTR0 0x00000300
+#define MSR_P4_BPU_PERFCTR1 0x00000301
+#define MSR_P4_BPU_PERFCTR2 0x00000302
+#define MSR_P4_BPU_PERFCTR3 0x00000303
+#define MSR_P4_MS_PERFCTR0 0x00000304
+#define MSR_P4_MS_PERFCTR1 0x00000305
+#define MSR_P4_MS_PERFCTR2 0x00000306
+#define MSR_P4_MS_PERFCTR3 0x00000307
+#define MSR_P4_FLAME_PERFCTR0 0x00000308
+#define MSR_P4_FLAME_PERFCTR1 0x00000309
+#define MSR_P4_FLAME_PERFCTR2 0x0000030a
+#define MSR_P4_FLAME_PERFCTR3 0x0000030b
+#define MSR_P4_IQ_PERFCTR0 0x0000030c
+#define MSR_P4_IQ_PERFCTR1 0x0000030d
+#define MSR_P4_IQ_PERFCTR2 0x0000030e
+#define MSR_P4_IQ_PERFCTR3 0x0000030f
+#define MSR_P4_IQ_PERFCTR4 0x00000310
+#define MSR_P4_IQ_PERFCTR5 0x00000311
+#define MSR_P4_BPU_CCCR0 0x00000360
+#define MSR_P4_BPU_CCCR1 0x00000361
+#define MSR_P4_BPU_CCCR2 0x00000362
+#define MSR_P4_BPU_CCCR3 0x00000363
+#define MSR_P4_MS_CCCR0 0x00000364
+#define MSR_P4_MS_CCCR1 0x00000365
+#define MSR_P4_MS_CCCR2 0x00000366
+#define MSR_P4_MS_CCCR3 0x00000367
+#define MSR_P4_FLAME_CCCR0 0x00000368
+#define MSR_P4_FLAME_CCCR1 0x00000369
+#define MSR_P4_FLAME_CCCR2 0x0000036a
+#define MSR_P4_FLAME_CCCR3 0x0000036b
+#define MSR_P4_IQ_CCCR0 0x0000036c
+#define MSR_P4_IQ_CCCR1 0x0000036d
+#define MSR_P4_IQ_CCCR2 0x0000036e
+#define MSR_P4_IQ_CCCR3 0x0000036f
+#define MSR_P4_IQ_CCCR4 0x00000370
+#define MSR_P4_IQ_CCCR5 0x00000371
+#define MSR_P4_ALF_ESCR0 0x000003ca
+#define MSR_P4_ALF_ESCR1 0x000003cb
+#define MSR_P4_BPU_ESCR0 0x000003b2
+#define MSR_P4_BPU_ESCR1 0x000003b3
+#define MSR_P4_BSU_ESCR0 0x000003a0
+#define MSR_P4_BSU_ESCR1 0x000003a1
+#define MSR_P4_CRU_ESCR0 0x000003b8
+#define MSR_P4_CRU_ESCR1 0x000003b9
+#define MSR_P4_CRU_ESCR2 0x000003cc
+#define MSR_P4_CRU_ESCR3 0x000003cd
+#define MSR_P4_CRU_ESCR4 0x000003e0
+#define MSR_P4_CRU_ESCR5 0x000003e1
+#define MSR_P4_DAC_ESCR0 0x000003a8
+#define MSR_P4_DAC_ESCR1 0x000003a9
+#define MSR_P4_FIRM_ESCR0 0x000003a4
+#define MSR_P4_FIRM_ESCR1 0x000003a5
+#define MSR_P4_FLAME_ESCR0 0x000003a6
+#define MSR_P4_FLAME_ESCR1 0x000003a7
+#define MSR_P4_FSB_ESCR0 0x000003a2
+#define MSR_P4_FSB_ESCR1 0x000003a3
+#define MSR_P4_IQ_ESCR0 0x000003ba
+#define MSR_P4_IQ_ESCR1 0x000003bb
+#define MSR_P4_IS_ESCR0 0x000003b4
+#define MSR_P4_IS_ESCR1 0x000003b5
+#define MSR_P4_ITLB_ESCR0 0x000003b6
+#define MSR_P4_ITLB_ESCR1 0x000003b7
+#define MSR_P4_IX_ESCR0 0x000003c8
+#define MSR_P4_IX_ESCR1 0x000003c9
+#define MSR_P4_MOB_ESCR0 0x000003aa
+#define MSR_P4_MOB_ESCR1 0x000003ab
+#define MSR_P4_MS_ESCR0 0x000003c0
+#define MSR_P4_MS_ESCR1 0x000003c1
+#define MSR_P4_PMH_ESCR0 0x000003ac
+#define MSR_P4_PMH_ESCR1 0x000003ad
+#define MSR_P4_RAT_ESCR0 0x000003bc
+#define MSR_P4_RAT_ESCR1 0x000003bd
+#define MSR_P4_SAAT_ESCR0 0x000003ae
+#define MSR_P4_SAAT_ESCR1 0x000003af
+#define MSR_P4_SSU_ESCR0 0x000003be
+#define MSR_P4_SSU_ESCR1 0x000003bf
+
+#define MSR_P4_TBPU_ESCR0 0x000003c2
+#define MSR_P4_TBPU_ESCR1 0x000003c3
+#define MSR_P4_TC_ESCR0 0x000003c4
+#define MSR_P4_TC_ESCR1 0x000003c5
+#define MSR_P4_U2L_ESCR0 0x000003b0
+#define MSR_P4_U2L_ESCR1 0x000003b1
+
+#define MSR_CORE_PERF_FIXED_CTR0 0x00000309
+#define MSR_CORE_PERF_FIXED_CTR1 0x0000030a
+#define MSR_CORE_PERF_FIXED_CTR2 0x0000030b
+#define MSR_CORE_PERF_FIXED_CTR_CTRL 0x0000038d
+#define MSR_CORE_PERF_GLOBAL_STATUS 0x0000038e
+#define MSR_CORE_PERF_GLOBAL_CTRL 0x0000038f
+#define MSR_CORE_PERF_GLOBAL_OVF_CTRL 0x00000390
+
+#define MSR_GEODE_BUSCONT_CONF0 0x00001900
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/msr.h b/libc/kernel/arch-x86/asm/msr.h
new file mode 100644
index 0000000..f1da917
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/msr.h
@@ -0,0 +1,54 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_X86_MSR_H_
+#define __ASM_X86_MSR_H_
+
+#include <asm/msr-index.h>
+
+#ifndef __ASSEMBLY__
+#include <linux/types.h>
+#endif
+
+#ifdef __i386__
+
+#else
+
+#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)
+
+#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")
+
+#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)
+
+#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
+#endif
diff --git a/libc/kernel/arch-x86/asm/page.h b/libc/kernel/arch-x86/asm/page.h
new file mode 100644
index 0000000..e6dcf27
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/page.h
@@ -0,0 +1,16 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifdef __i386__
+#include "page_32.h"
+#else
+#include "page_64.h"
+#endif
diff --git a/libc/kernel/arch-x86/asm/page_32.h b/libc/kernel/arch-x86/asm/page_32.h
new file mode 100644
index 0000000..718cf95
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/page_32.h
@@ -0,0 +1,22 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _I386_PAGE_H
+#define _I386_PAGE_H
+
+#define PAGE_SHIFT 12
+#define PAGE_SIZE (1UL << PAGE_SHIFT)
+#define PAGE_MASK (~(PAGE_SIZE-1))
+
+#define LARGE_PAGE_MASK (~(LARGE_PAGE_SIZE-1))
+#define LARGE_PAGE_SIZE (1UL << PMD_SHIFT)
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/param.h b/libc/kernel/arch-x86/asm/param.h
new file mode 100644
index 0000000..0825173
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/param.h
@@ -0,0 +1,27 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_PARAM_H
+#define _ASM_X86_PARAM_H
+
+#ifndef HZ
+#define HZ 100
+#endif
+
+#define EXEC_PAGESIZE 4096
+
+#ifndef NOGROUP
+#define NOGROUP (-1)
+#endif
+
+#define MAXHOSTNAMELEN 64
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/paravirt.h b/libc/kernel/arch-x86/asm/paravirt.h
new file mode 100644
index 0000000..ab0d08e
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/paravirt.h
@@ -0,0 +1,15 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_PARAVIRT_H
+#define __ASM_PARAVIRT_H
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/pda.h b/libc/kernel/arch-x86/asm/pda.h
new file mode 100644
index 0000000..6711224
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/pda.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef X86_64_PDA_H
+#define X86_64_PDA_H
+
+#ifndef __ASSEMBLY__
+#include <linux/stddef.h>
+#include <linux/types.h>
+#include <linux/cache.h>
+#include <asm/page.h>
+
+struct x8664_pda {
+ struct task_struct *pcurrent;
+ unsigned long data_offset;
+ unsigned long kernelstack;
+ unsigned long oldrsp;
+ int irqcount;
+ int cpunumber;
+ char *irqstackptr;
+ int nodenumber;
+ unsigned int __softirq_pending;
+ unsigned int __nmi_count;
+ short mmu_state;
+ short isidle;
+ struct mm_struct *active_mm;
+ unsigned apic_timer_irqs;
+ unsigned irq0_irqs;
+ unsigned irq_resched_count;
+ unsigned irq_call_count;
+ unsigned irq_tlb_count;
+ unsigned irq_thermal_count;
+ unsigned irq_threshold_count;
+ unsigned irq_spurious_count;
+} ____cacheline_aligned_in_smp;
+
+#define cpu_pda(i) (_cpu_pda[i])
+
+#define pda_offset(field) offsetof(struct x8664_pda, field)
+
+#define pda_to_op(op,field,val) do { typedef typeof(_proxy_pda.field) T__; if (0) { T__ tmp__; tmp__ = (val); } switch (sizeof(_proxy_pda.field)) { case 2: asm(op "w %1,%%gs:%c2" : "+m" (_proxy_pda.field) : "ri" ((T__)val), "i"(pda_offset(field))); break; case 4: asm(op "l %1,%%gs:%c2" : "+m" (_proxy_pda.field) : "ri" ((T__)val), "i" (pda_offset(field))); break; case 8: asm(op "q %1,%%gs:%c2": "+m" (_proxy_pda.field) : "ri" ((T__)val), "i"(pda_offset(field))); break; default: __bad_pda_field(); } } while (0)
+
+#define pda_from_op(op,field) ({ typeof(_proxy_pda.field) ret__; switch (sizeof(_proxy_pda.field)) { case 2: asm(op "w %%gs:%c1,%0" : "=r" (ret__) : "i" (pda_offset(field)), "m" (_proxy_pda.field)); break; case 4: asm(op "l %%gs:%c1,%0": "=r" (ret__): "i" (pda_offset(field)), "m" (_proxy_pda.field)); break; case 8: asm(op "q %%gs:%c1,%0": "=r" (ret__) : "i" (pda_offset(field)), "m" (_proxy_pda.field)); break; default: __bad_pda_field(); } ret__; })
+
+#define read_pda(field) pda_from_op("mov",field)
+#define write_pda(field,val) pda_to_op("mov",field,val)
+#define add_pda(field,val) pda_to_op("add",field,val)
+#define sub_pda(field,val) pda_to_op("sub",field,val)
+#define or_pda(field,val) pda_to_op("or",field,val)
+
+#define test_and_clear_bit_pda(bit,field) ({ int old__; asm volatile("btr %2,%%gs:%c3\n\tsbbl %0,%0" : "=r" (old__), "+m" (_proxy_pda.field) : "dIr" (bit), "i" (pda_offset(field)) : "memory"); old__; })
+
+#endif
+
+#define PDA_STACKOFFSET (5*8)
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/percpu.h b/libc/kernel/arch-x86/asm/percpu.h
new file mode 100644
index 0000000..7740e67
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/percpu.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "percpu_64.h"
diff --git a/libc/kernel/arch-x86/asm/percpu_32.h b/libc/kernel/arch-x86/asm/percpu_32.h
new file mode 100644
index 0000000..21135d6
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/percpu_32.h
@@ -0,0 +1,36 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ARCH_I386_PERCPU__
+#define __ARCH_I386_PERCPU__
+
+#ifdef __ASSEMBLY__
+
+#define PER_CPU(var, reg) movl $per_cpu__##var, reg
+#define PER_CPU_VAR(var) per_cpu__##var
+
+#else
+
+#include <asm-generic/percpu.h>
+#define __percpu_seg ""
+
+#define percpu_to_op(op,var,val) do { typedef typeof(var) T__; if (0) { T__ tmp__; tmp__ = (val); } switch (sizeof(var)) { case 1: asm(op "b %1,"__percpu_seg"%0" : "+m" (var) :"ri" ((T__)val)); break; case 2: asm(op "w %1,"__percpu_seg"%0" : "+m" (var) :"ri" ((T__)val)); break; case 4: asm(op "l %1,"__percpu_seg"%0" : "+m" (var) :"ri" ((T__)val)); break; default: __bad_percpu_size(); } } while (0)
+
+#define percpu_from_op(op,var) ({ typeof(var) ret__; switch (sizeof(var)) { case 1: asm(op "b "__percpu_seg"%1,%0" : "=r" (ret__) : "m" (var)); break; case 2: asm(op "w "__percpu_seg"%1,%0" : "=r" (ret__) : "m" (var)); break; case 4: asm(op "l "__percpu_seg"%1,%0" : "=r" (ret__) : "m" (var)); break; default: __bad_percpu_size(); } ret__; })
+
+#define x86_read_percpu(var) percpu_from_op("mov", per_cpu__##var)
+#define x86_write_percpu(var,val) percpu_to_op("mov", per_cpu__##var, val)
+#define x86_add_percpu(var,val) percpu_to_op("add", per_cpu__##var, val)
+#define x86_sub_percpu(var,val) percpu_to_op("sub", per_cpu__##var, val)
+#define x86_or_percpu(var,val) percpu_to_op("or", per_cpu__##var, val)
+#endif
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/pgalloc.h b/libc/kernel/arch-x86/asm/pgalloc.h
new file mode 100644
index 0000000..d5a032b
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/pgalloc.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "pgalloc_64.h"
diff --git a/libc/kernel/arch-x86/asm/pgalloc_32.h b/libc/kernel/arch-x86/asm/pgalloc_32.h
new file mode 100644
index 0000000..bc0f884
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/pgalloc_32.h
@@ -0,0 +1,30 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _I386_PGALLOC_H
+#define _I386_PGALLOC_H
+
+#include <linux/threads.h>
+#include <linux/mm.h>
+
+#define paravirt_alloc_pt(mm, pfn) do { } while (0)
+#define paravirt_alloc_pd(pfn) do { } while (0)
+#define paravirt_alloc_pd(pfn) do { } while (0)
+#define paravirt_alloc_pd_clone(pfn, clonepfn, start, count) do { } while (0)
+#define paravirt_release_pt(pfn) do { } while (0)
+#define paravirt_release_pd(pfn) do { } while (0)
+
+#define pmd_populate_kernel(mm, pmd, pte) do { paravirt_alloc_pt(mm, __pa(pte) >> PAGE_SHIFT); set_pmd(pmd, __pmd(_PAGE_TABLE + __pa(pte))); } while (0)
+
+#define pmd_populate(mm, pmd, pte) do { paravirt_alloc_pt(mm, page_to_pfn(pte)); set_pmd(pmd, __pmd(_PAGE_TABLE + ((unsigned long long)page_to_pfn(pte) << (unsigned long long) PAGE_SHIFT))); } while (0)
+
+#define __pte_free_tlb(tlb,pte) do { paravirt_release_pt(page_to_pfn(pte)); tlb_remove_page((tlb),(pte)); } while (0)
+#endif
diff --git a/libc/kernel/arch-x86/asm/pgtable-2level-defs.h b/libc/kernel/arch-x86/asm/pgtable-2level-defs.h
new file mode 100644
index 0000000..9edc6c5
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/pgtable-2level-defs.h
@@ -0,0 +1,22 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _I386_PGTABLE_2LEVEL_DEFS_H
+#define _I386_PGTABLE_2LEVEL_DEFS_H
+
+#define SHARED_KERNEL_PMD 0
+
+#define PGDIR_SHIFT 22
+#define PTRS_PER_PGD 1024
+
+#define PTRS_PER_PTE 1024
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/pgtable-2level.h b/libc/kernel/arch-x86/asm/pgtable-2level.h
new file mode 100644
index 0000000..7ade4ed
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/pgtable-2level.h
@@ -0,0 +1,39 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _I386_PGTABLE_2LEVEL_H
+#define _I386_PGTABLE_2LEVEL_H
+
+#define pte_ERROR(e) printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, (e).pte_low)
+#define pgd_ERROR(e) printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
+
+#define set_pte(pteptr, pteval) native_set_pte(pteptr, pteval)
+#define set_pte_at(mm,addr,ptep,pteval) native_set_pte_at(mm, addr, ptep, pteval)
+#define set_pmd(pmdptr, pmdval) native_set_pmd(pmdptr, pmdval)
+#define set_pte_atomic(pteptr, pteval) set_pte(pteptr,pteval)
+#define set_pte_present(mm,addr,ptep,pteval) set_pte_at(mm,addr,ptep,pteval)
+#define pte_clear(mm,addr,xp) do { set_pte_at(mm, addr, xp, __pte(0)); } while (0)
+#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0)
+#define native_ptep_get_and_clear(xp) native_local_ptep_get_and_clear(xp)
+#define pte_page(x) pfn_to_page(pte_pfn(x))
+#define pte_none(x) (!(x).pte_low)
+#define pte_pfn(x) (pte_val(x) >> PAGE_SHIFT)
+#define pfn_pte(pfn, prot) __pte(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
+#define pfn_pmd(pfn, prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
+#define PTE_FILE_MAX_BITS 29
+#define pte_to_pgoff(pte) ((((pte).pte_low >> 1) & 0x1f ) + (((pte).pte_low >> 8) << 5 ))
+#define pgoff_to_pte(off) ((pte_t) { (((off) & 0x1f) << 1) + (((off) >> 5) << 8) + _PAGE_FILE })
+#define __swp_type(x) (((x).val >> 1) & 0x1f)
+#define __swp_offset(x) ((x).val >> 8)
+#define __swp_entry(type, offset) ((swp_entry_t) { ((type) << 1) | ((offset) << 8) })
+#define __pte_to_swp_entry(pte) ((swp_entry_t) { (pte).pte_low })
+#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
+#endif
diff --git a/libc/kernel/arch-x86/asm/pgtable.h b/libc/kernel/arch-x86/asm/pgtable.h
new file mode 100644
index 0000000..797e473
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/pgtable.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "pgtable_64.h"
diff --git a/libc/kernel/arch-x86/asm/pgtable_32.h b/libc/kernel/arch-x86/asm/pgtable_32.h
new file mode 100644
index 0000000..c63ba93
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/pgtable_32.h
@@ -0,0 +1,175 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _I386_PGTABLE_H
+#define _I386_PGTABLE_H
+
+#ifndef __ASSEMBLY__
+#include <asm/processor.h>
+#include <asm/fixmap.h>
+#include <linux/threads.h>
+#include <asm/paravirt.h>
+
+#include <linux/bitops.h>
+#include <linux/slab.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+
+struct mm_struct;
+struct vm_area_struct;
+
+#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
+
+#include <asm/pgtable-2level-defs.h>
+
+#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
+#define PGDIR_MASK (~(PGDIR_SIZE-1))
+
+#define USER_PTRS_PER_PGD (TASK_SIZE/PGDIR_SIZE)
+#define FIRST_USER_ADDRESS 0
+
+#define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT)
+#define KERNEL_PGD_PTRS (PTRS_PER_PGD-USER_PGD_PTRS)
+
+#define TWOLEVEL_PGDIR_SHIFT 22
+#define BOOT_USER_PGD_PTRS (__PAGE_OFFSET >> TWOLEVEL_PGDIR_SHIFT)
+#define BOOT_KERNEL_PGD_PTRS (1024-BOOT_USER_PGD_PTRS)
+
+#define VMALLOC_OFFSET (8*1024*1024)
+#define VMALLOC_START (((unsigned long) high_memory + 2*VMALLOC_OFFSET-1) & ~(VMALLOC_OFFSET-1))
+#define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE)
+
+#define _PAGE_BIT_PRESENT 0
+#define _PAGE_BIT_RW 1
+#define _PAGE_BIT_USER 2
+#define _PAGE_BIT_PWT 3
+#define _PAGE_BIT_PCD 4
+#define _PAGE_BIT_ACCESSED 5
+#define _PAGE_BIT_DIRTY 6
+#define _PAGE_BIT_PSE 7
+#define _PAGE_BIT_GLOBAL 8
+#define _PAGE_BIT_UNUSED1 9
+#define _PAGE_BIT_UNUSED2 10
+#define _PAGE_BIT_UNUSED3 11
+#define _PAGE_BIT_NX 63
+
+#define _PAGE_PRESENT 0x001
+#define _PAGE_RW 0x002
+#define _PAGE_USER 0x004
+#define _PAGE_PWT 0x008
+#define _PAGE_PCD 0x010
+#define _PAGE_ACCESSED 0x020
+#define _PAGE_DIRTY 0x040
+#define _PAGE_PSE 0x080
+#define _PAGE_GLOBAL 0x100
+#define _PAGE_UNUSED1 0x200
+#define _PAGE_UNUSED2 0x400
+#define _PAGE_UNUSED3 0x800
+
+#define _PAGE_FILE 0x040
+#define _PAGE_PROTNONE 0x080
+#define _PAGE_NX 0
+
+#define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY)
+#define _KERNPG_TABLE (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED | _PAGE_DIRTY)
+#define _PAGE_CHG_MASK (PTE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY)
+
+#define PAGE_NONE __pgprot(_PAGE_PROTNONE | _PAGE_ACCESSED)
+#define PAGE_SHARED __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED)
+
+#define PAGE_SHARED_EXEC __pgprot(_PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED)
+#define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX)
+#define PAGE_COPY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
+#define PAGE_COPY PAGE_COPY_NOEXEC
+#define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED | _PAGE_NX)
+#define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_ACCESSED)
+
+#define _PAGE_KERNEL (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_NX)
+#define _PAGE_KERNEL_EXEC (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED)
+
+#define __PAGE_KERNEL_RO (__PAGE_KERNEL & ~_PAGE_RW)
+#define __PAGE_KERNEL_RX (__PAGE_KERNEL_EXEC & ~_PAGE_RW)
+#define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD)
+#define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
+#define __PAGE_KERNEL_LARGE_EXEC (__PAGE_KERNEL_EXEC | _PAGE_PSE)
+
+#define PAGE_KERNEL __pgprot(__PAGE_KERNEL)
+#define PAGE_KERNEL_RO __pgprot(__PAGE_KERNEL_RO)
+#define PAGE_KERNEL_EXEC __pgprot(__PAGE_KERNEL_EXEC)
+#define PAGE_KERNEL_RX __pgprot(__PAGE_KERNEL_RX)
+#define PAGE_KERNEL_NOCACHE __pgprot(__PAGE_KERNEL_NOCACHE)
+#define PAGE_KERNEL_LARGE __pgprot(__PAGE_KERNEL_LARGE)
+#define PAGE_KERNEL_LARGE_EXEC __pgprot(__PAGE_KERNEL_LARGE_EXEC)
+
+#define __P000 PAGE_NONE
+#define __P001 PAGE_READONLY
+#define __P010 PAGE_COPY
+#define __P011 PAGE_COPY
+#define __P100 PAGE_READONLY_EXEC
+#define __P101 PAGE_READONLY_EXEC
+#define __P110 PAGE_COPY_EXEC
+#define __P111 PAGE_COPY_EXEC
+
+#define __S000 PAGE_NONE
+#define __S001 PAGE_READONLY
+#define __S010 PAGE_SHARED
+#define __S011 PAGE_SHARED
+#define __S100 PAGE_READONLY_EXEC
+#define __S101 PAGE_READONLY_EXEC
+#define __S110 PAGE_SHARED_EXEC
+#define __S111 PAGE_SHARED_EXEC
+
+#undef TEST_ACCESS_OK
+
+#define pte_present(x) ((x).pte_low & (_PAGE_PRESENT | _PAGE_PROTNONE))
+
+#define pmd_none(x) (!(unsigned long)pmd_val(x))
+#define pmd_present(x) (pmd_val(x) & _PAGE_PRESENT)
+#define pmd_bad(x) ((pmd_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE)
+
+#define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT))
+
+#include <asm/pgtable-2level.h>
+#define pte_update(mm, addr, ptep) do { } while (0)
+#define pte_update_defer(mm, addr, ptep) do { } while (0)
+#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
+#define ptep_set_access_flags(vma, address, ptep, entry, dirty) ({ int __changed = !pte_same(*(ptep), entry); if (__changed && dirty) { (ptep)->pte_low = (entry).pte_low; pte_update_defer((vma)->vm_mm, (address), (ptep)); flush_tlb_page(vma, address); } __changed; })
+#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
+#define ptep_test_and_clear_young(vma, addr, ptep) ({ int __ret = 0; if (pte_young(*(ptep))) __ret = test_and_clear_bit(_PAGE_BIT_ACCESSED, &(ptep)->pte_low); if (__ret) pte_update((vma)->vm_mm, addr, ptep); __ret; })
+#define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
+#define ptep_clear_flush_young(vma, address, ptep) ({ int __young; __young = ptep_test_and_clear_young((vma), (address), (ptep)); if (__young) flush_tlb_page(vma, address); __young; })
+#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
+#define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL
+#define __HAVE_ARCH_PTEP_SET_WRPROTECT
+#define pgprot_noncached(prot) ((boot_cpu_data.x86 > 3) ? (__pgprot(pgprot_val(prot) | _PAGE_PCD | _PAGE_PWT)) : (prot))
+#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
+#define pmd_large(pmd) ((pmd_val(pmd) & (_PAGE_PSE|_PAGE_PRESENT)) == (_PAGE_PSE|_PAGE_PRESENT))
+#define pgd_index(address) (((address) >> PGDIR_SHIFT) & (PTRS_PER_PGD-1))
+#define pgd_index_k(addr) pgd_index(addr)
+#define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address))
+#define pgd_offset_k(address) pgd_offset(&init_mm, address)
+#define pmd_index(address) (((address) >> PMD_SHIFT) & (PTRS_PER_PMD-1))
+#define pte_index(address) (((address) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))
+#define pte_offset_kernel(dir, address) ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(address))
+#define pmd_page(pmd) (pfn_to_page(pmd_val(pmd) >> PAGE_SHIFT))
+#define pmd_page_vaddr(pmd) ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
+
+ #define pte_offset_map(dir, address) ((pte_t *)page_address(pmd_page(*(dir))) + pte_index(address))
+#define pte_offset_map_nested(dir, address) pte_offset_map(dir, address)
+#define pte_unmap(pte) do { } while (0)
+#define pte_unmap_nested(pte) do { } while (0)
+#define kpte_clear_flush(ptep, vaddr) do { pte_clear(&init_mm, vaddr, ptep); __flush_tlb_one(vaddr); } while (0)
+#define update_mmu_cache(vma,address,pte) do { } while (0)
+
+#endif
+#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) remap_pfn_range(vma, vaddr, pfn, size, prot)
+#include <asm-generic/pgtable.h>
+#endif
diff --git a/libc/kernel/arch-x86/asm/poll.h b/libc/kernel/arch-x86/asm/poll.h
new file mode 100644
index 0000000..5b16673
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/poll.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include <asm-generic/poll.h>
diff --git a/libc/kernel/arch-x86/asm/posix_types.h b/libc/kernel/arch-x86/asm/posix_types.h
new file mode 100644
index 0000000..79bb490
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/posix_types.h
@@ -0,0 +1,16 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifdef __i386__
+#include "posix_types_32.h"
+#else
+#include "posix_types_64.h"
+#endif
diff --git a/libc/kernel/arch-x86/asm/posix_types_32.h b/libc/kernel/arch-x86/asm/posix_types_32.h
new file mode 100644
index 0000000..97a8b69
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/posix_types_32.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ARCH_I386_POSIX_TYPES_H
+#define __ARCH_I386_POSIX_TYPES_H
+
+typedef unsigned long __kernel_ino_t;
+typedef unsigned short __kernel_mode_t;
+typedef unsigned short __kernel_nlink_t;
+typedef long __kernel_off_t;
+typedef int __kernel_pid_t;
+typedef unsigned short __kernel_ipc_pid_t;
+typedef unsigned short __kernel_uid_t;
+typedef unsigned short __kernel_gid_t;
+typedef unsigned int __kernel_size_t;
+typedef int __kernel_ssize_t;
+typedef int __kernel_ptrdiff_t;
+typedef long __kernel_time_t;
+typedef long __kernel_suseconds_t;
+typedef long __kernel_clock_t;
+typedef int __kernel_timer_t;
+typedef int __kernel_clockid_t;
+typedef int __kernel_daddr_t;
+typedef char * __kernel_caddr_t;
+typedef unsigned short __kernel_uid16_t;
+typedef unsigned short __kernel_gid16_t;
+typedef unsigned int __kernel_uid32_t;
+typedef unsigned int __kernel_gid32_t;
+
+typedef unsigned short __kernel_old_uid_t;
+typedef unsigned short __kernel_old_gid_t;
+typedef unsigned short __kernel_old_dev_t;
+
+#ifdef __GNUC__
+typedef long long __kernel_loff_t;
+#endif
+
+typedef struct {
+#ifdef __USE_ALL
+ int val[2];
+#else
+ int __val[2];
+#endif
+} __kernel_fsid_t;
+
+#if !defined(__GLIBC__) || __GLIBC__ < 2
+
+#undef __FD_SET
+#define __FD_SET(fd,fdsetp) __asm__ __volatile__("btsl %1,%0": "+m" (*(__kernel_fd_set *) (fdsetp)):"r" ((int) (fd)))
+
+#undef __FD_CLR
+#define __FD_CLR(fd,fdsetp) __asm__ __volatile__("btrl %1,%0": "+m" (*(__kernel_fd_set *) (fdsetp)):"r" ((int) (fd)))
+
+#undef __FD_ISSET
+#define __FD_ISSET(fd,fdsetp) (__extension__ ({ unsigned char __result; __asm__ __volatile__("btl %1,%2 ; setb %0" :"=q" (__result) :"r" ((int) (fd)), "m" (*(__kernel_fd_set *) (fdsetp))); __result; }))
+
+#undef __FD_ZERO
+#define __FD_ZERO(fdsetp) do { int __d0, __d1; __asm__ __volatile__("cld ; rep ; stosl" :"=m" (*(__kernel_fd_set *) (fdsetp)), "=&c" (__d0), "=&D" (__d1) :"a" (0), "1" (__FDSET_LONGS), "2" ((__kernel_fd_set *) (fdsetp)) : "memory"); } while (0)
+
+#endif
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/prctl.h b/libc/kernel/arch-x86/asm/prctl.h
new file mode 100644
index 0000000..8852ca7
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/prctl.h
@@ -0,0 +1,20 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef X86_64_PRCTL_H
+#define X86_64_PRCTL_H 1
+
+#define ARCH_SET_GS 0x1001
+#define ARCH_SET_FS 0x1002
+#define ARCH_GET_FS 0x1003
+#define ARCH_GET_GS 0x1004
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/processor-flags.h b/libc/kernel/arch-x86/asm/processor-flags.h
new file mode 100644
index 0000000..79e8f7d
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/processor-flags.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_I386_PROCESSOR_FLAGS_H
+#define __ASM_I386_PROCESSOR_FLAGS_H
+
+#define X86_EFLAGS_CF 0x00000001
+#define X86_EFLAGS_PF 0x00000004
+#define X86_EFLAGS_AF 0x00000010
+#define X86_EFLAGS_ZF 0x00000040
+#define X86_EFLAGS_SF 0x00000080
+#define X86_EFLAGS_TF 0x00000100
+#define X86_EFLAGS_IF 0x00000200
+#define X86_EFLAGS_DF 0x00000400
+#define X86_EFLAGS_OF 0x00000800
+#define X86_EFLAGS_IOPL 0x00003000
+#define X86_EFLAGS_NT 0x00004000
+#define X86_EFLAGS_RF 0x00010000
+#define X86_EFLAGS_VM 0x00020000
+#define X86_EFLAGS_AC 0x00040000
+#define X86_EFLAGS_VIF 0x00080000
+#define X86_EFLAGS_VIP 0x00100000
+#define X86_EFLAGS_ID 0x00200000
+
+#define X86_CR0_PE 0x00000001
+#define X86_CR0_MP 0x00000002
+#define X86_CR0_EM 0x00000004
+#define X86_CR0_TS 0x00000008
+#define X86_CR0_ET 0x00000010
+#define X86_CR0_NE 0x00000020
+#define X86_CR0_WP 0x00010000
+#define X86_CR0_AM 0x00040000
+#define X86_CR0_NW 0x20000000
+#define X86_CR0_CD 0x40000000
+#define X86_CR0_PG 0x80000000
+
+#define X86_CR3_PWT 0x00000008
+#define X86_CR3_PCD 0x00000010
+
+#define X86_CR4_VME 0x00000001
+#define X86_CR4_PVI 0x00000002
+#define X86_CR4_TSD 0x00000004
+#define X86_CR4_DE 0x00000008
+#define X86_CR4_PSE 0x00000010
+#define X86_CR4_PAE 0x00000020
+#define X86_CR4_MCE 0x00000040
+#define X86_CR4_PGE 0x00000080
+#define X86_CR4_PCE 0x00000100
+#define X86_CR4_OSFXSR 0x00000200
+#define X86_CR4_OSXMMEXCPT 0x00000400
+#define X86_CR4_VMXE 0x00002000
+
+#define X86_CR8_TPR 0x0000000F
+
+#define CX86_PCR0 0x20
+#define CX86_GCR 0xb8
+#define CX86_CCR0 0xc0
+#define CX86_CCR1 0xc1
+#define CX86_CCR2 0xc2
+#define CX86_CCR3 0xc3
+#define CX86_CCR4 0xe8
+#define CX86_CCR5 0xe9
+#define CX86_CCR6 0xea
+#define CX86_CCR7 0xeb
+#define CX86_PCR1 0xf0
+#define CX86_DIR0 0xfe
+#define CX86_DIR1 0xff
+#define CX86_ARR_BASE 0xc4
+#define CX86_RCR_BASE 0xdc
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/processor.h b/libc/kernel/arch-x86/asm/processor.h
new file mode 100644
index 0000000..7d47749
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/processor.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "processor_64.h"
diff --git a/libc/kernel/arch-x86/asm/processor_32.h b/libc/kernel/arch-x86/asm/processor_32.h
new file mode 100644
index 0000000..539edd1
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/processor_32.h
@@ -0,0 +1,324 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_I386_PROCESSOR_H
+#define __ASM_I386_PROCESSOR_H
+
+#include <asm/vm86.h>
+#include <asm/math_emu.h>
+#include <asm/segment.h>
+#include <asm/page.h>
+#include <asm/types.h>
+#include <asm/sigcontext.h>
+#include <asm/cpufeature.h>
+#include <asm/msr.h>
+#include <asm/system.h>
+#include <linux/cache.h>
+#include <linux/threads.h>
+#include <asm/percpu.h>
+#include <linux/cpumask.h>
+#include <linux/init.h>
+#include <asm/processor-flags.h>
+
+struct desc_struct {
+ unsigned long a,b;
+};
+
+#define desc_empty(desc) (!((desc)->a | (desc)->b))
+
+#define desc_equal(desc1, desc2) (((desc1)->a == (desc2)->a) && ((desc1)->b == (desc2)->b))
+
+#define current_text_addr() ({ void *pc; __asm__("movl $1f,%0\n1:":"=g" (pc)); pc; })
+
+struct cpuinfo_x86 {
+ __u8 x86;
+ __u8 x86_vendor;
+ __u8 x86_model;
+ __u8 x86_mask;
+ char wp_works_ok;
+ char hlt_works_ok;
+ char hard_math;
+ char rfu;
+ int cpuid_level;
+ unsigned long x86_capability[NCAPINTS];
+ char x86_vendor_id[16];
+ char x86_model_id[64];
+ int x86_cache_size;
+ int x86_cache_alignment;
+ char fdiv_bug;
+ char f00f_bug;
+ char coma_bug;
+ char pad0;
+ int x86_power;
+ unsigned long loops_per_jiffy;
+ unsigned char x86_max_cores;
+ unsigned char apicid;
+ unsigned short x86_clflush_size;
+} __attribute__((__aligned__(SMP_CACHE_BYTES)));
+
+#define X86_VENDOR_INTEL 0
+#define X86_VENDOR_CYRIX 1
+#define X86_VENDOR_AMD 2
+#define X86_VENDOR_UMC 3
+#define X86_VENDOR_NEXGEN 4
+#define X86_VENDOR_CENTAUR 5
+#define X86_VENDOR_TRANSMETA 7
+#define X86_VENDOR_NSC 8
+#define X86_VENDOR_NUM 9
+#define X86_VENDOR_UNKNOWN 0xff
+
+#define cpu_data(cpu) boot_cpu_data
+#define current_cpu_data boot_cpu_data
+
+#define load_cr3(pgdir) write_cr3(__pa(pgdir))
+
+#define TASK_SIZE (PAGE_OFFSET)
+
+#define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
+
+#define HAVE_ARCH_PICK_MMAP_LAYOUT
+
+#define IO_BITMAP_BITS 65536
+#define IO_BITMAP_BYTES (IO_BITMAP_BITS/8)
+#define IO_BITMAP_LONGS (IO_BITMAP_BYTES/sizeof(long))
+#define IO_BITMAP_OFFSET offsetof(struct tss_struct,io_bitmap)
+#define INVALID_IO_BITMAP_OFFSET 0x8000
+#define INVALID_IO_BITMAP_OFFSET_LAZY 0x9000
+
+struct i387_fsave_struct {
+ long cwd;
+ long swd;
+ long twd;
+ long fip;
+ long fcs;
+ long foo;
+ long fos;
+ long st_space[20];
+ long status;
+};
+
+struct i387_fxsave_struct {
+ unsigned short cwd;
+ unsigned short swd;
+ unsigned short twd;
+ unsigned short fop;
+ long fip;
+ long fcs;
+ long foo;
+ long fos;
+ long mxcsr;
+ long mxcsr_mask;
+ long st_space[32];
+ long xmm_space[32];
+ long padding[56];
+} __attribute__ ((aligned (16)));
+
+struct i387_soft_struct {
+ long cwd;
+ long swd;
+ long twd;
+ long fip;
+ long fcs;
+ long foo;
+ long fos;
+ long st_space[20];
+ unsigned char ftop, changed, lookahead, no_update, rm, alimit;
+ struct info *info;
+ unsigned long entry_eip;
+};
+
+union i387_union {
+ struct i387_fsave_struct fsave;
+ struct i387_fxsave_struct fxsave;
+ struct i387_soft_struct soft;
+};
+
+typedef struct {
+ unsigned long seg;
+} mm_segment_t;
+
+struct thread_struct;
+
+struct i386_hw_tss {
+ unsigned short back_link,__blh;
+ unsigned long esp0;
+ unsigned short ss0,__ss0h;
+ unsigned long esp1;
+ unsigned short ss1,__ss1h;
+ unsigned long esp2;
+ unsigned short ss2,__ss2h;
+ unsigned long __cr3;
+ unsigned long eip;
+ unsigned long eflags;
+ unsigned long eax,ecx,edx,ebx;
+ unsigned long esp;
+ unsigned long ebp;
+ unsigned long esi;
+ unsigned long edi;
+ unsigned short es, __esh;
+ unsigned short cs, __csh;
+ unsigned short ss, __ssh;
+ unsigned short ds, __dsh;
+ unsigned short fs, __fsh;
+ unsigned short gs, __gsh;
+ unsigned short ldt, __ldth;
+ unsigned short trace, io_bitmap_base;
+} __attribute__((packed));
+
+struct tss_struct {
+ struct i386_hw_tss x86_tss;
+
+ unsigned long io_bitmap[IO_BITMAP_LONGS + 1];
+
+ unsigned long io_bitmap_max;
+ struct thread_struct *io_bitmap_owner;
+
+ unsigned long __cacheline_filler[35];
+
+ unsigned long stack[64];
+} __attribute__((packed));
+
+#define ARCH_MIN_TASKALIGN 16
+
+struct thread_struct {
+
+ struct desc_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
+ unsigned long esp0;
+ unsigned long sysenter_cs;
+ unsigned long eip;
+ unsigned long esp;
+ unsigned long fs;
+ unsigned long gs;
+
+ unsigned long debugreg[8];
+
+ unsigned long cr2, trap_no, error_code;
+
+ union i387_union i387;
+
+ struct vm86_struct __user * vm86_info;
+ unsigned long screen_bitmap;
+ unsigned long v86flags, v86mask, saved_esp0;
+ unsigned int saved_fs, saved_gs;
+
+ unsigned long *io_bitmap_ptr;
+ unsigned long iopl;
+
+ unsigned long io_bitmap_max;
+};
+
+#define INIT_THREAD { .esp0 = sizeof(init_stack) + (long)&init_stack, .vm86_info = NULL, .sysenter_cs = __KERNEL_CS, .io_bitmap_ptr = NULL, .fs = __KERNEL_PERCPU, }
+
+#define INIT_TSS { .x86_tss = { .esp0 = sizeof(init_stack) + (long)&init_stack, .ss0 = __KERNEL_DS, .ss1 = __KERNEL_CS, .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, }, .io_bitmap = { [ 0 ... IO_BITMAP_LONGS] = ~0 }, }
+
+#define start_thread(regs, new_eip, new_esp) do { __asm__("movl %0,%%gs": :"r" (0)); regs->xfs = 0; set_fs(USER_DS); regs->xds = __USER_DS; regs->xes = __USER_DS; regs->xss = __USER_DS; regs->xcs = __USER_CS; regs->eip = new_eip; regs->esp = new_esp; } while (0)
+
+struct task_struct;
+struct mm_struct;
+
+#define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
+#define KSTK_TOP(info) ({ unsigned long *__ptr = (unsigned long *)(info); (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); })
+
+#define task_pt_regs(task) ({ struct pt_regs *__regs__; __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); __regs__ - 1; })
+
+#define KSTK_EIP(task) (task_pt_regs(task)->eip)
+#define KSTK_ESP(task) (task_pt_regs(task)->esp)
+
+struct microcode_header {
+ unsigned int hdrver;
+ unsigned int rev;
+ unsigned int date;
+ unsigned int sig;
+ unsigned int cksum;
+ unsigned int ldrver;
+ unsigned int pf;
+ unsigned int datasize;
+ unsigned int totalsize;
+ unsigned int reserved[3];
+};
+
+struct microcode {
+ struct microcode_header hdr;
+ unsigned int bits[0];
+};
+
+typedef struct microcode microcode_t;
+typedef struct microcode_header microcode_header_t;
+
+struct extended_signature {
+ unsigned int sig;
+ unsigned int pf;
+ unsigned int cksum;
+};
+
+struct extended_sigtable {
+ unsigned int count;
+ unsigned int cksum;
+ unsigned int reserved[3];
+ struct extended_signature sigs[0];
+};
+
+#define cpu_relax() rep_nop()
+#define paravirt_enabled() 0
+#define __cpuid native_cpuid
+#define get_debugreg(var, register) (var) = native_get_debugreg(register)
+#define set_debugreg(value, register) native_set_debugreg(register, value)
+#define set_iopl_mask native_set_iopl_mask
+#define GENERIC_NOP1 ".byte 0x90\n"
+#define GENERIC_NOP2 ".byte 0x89,0xf6\n"
+#define GENERIC_NOP3 ".byte 0x8d,0x76,0x00\n"
+#define GENERIC_NOP4 ".byte 0x8d,0x74,0x26,0x00\n"
+#define GENERIC_NOP5 GENERIC_NOP1 GENERIC_NOP4
+#define GENERIC_NOP6 ".byte 0x8d,0xb6,0x00,0x00,0x00,0x00\n"
+#define GENERIC_NOP7 ".byte 0x8d,0xb4,0x26,0x00,0x00,0x00,0x00\n"
+#define GENERIC_NOP8 GENERIC_NOP1 GENERIC_NOP7
+#define K8_NOP1 GENERIC_NOP1
+#define K8_NOP2 ".byte 0x66,0x90\n"
+#define K8_NOP3 ".byte 0x66,0x66,0x90\n"
+#define K8_NOP4 ".byte 0x66,0x66,0x66,0x90\n"
+#define K8_NOP5 K8_NOP3 K8_NOP2
+#define K8_NOP6 K8_NOP3 K8_NOP3
+#define K8_NOP7 K8_NOP4 K8_NOP3
+#define K8_NOP8 K8_NOP4 K8_NOP4
+#define K7_NOP1 GENERIC_NOP1
+#define K7_NOP2 ".byte 0x8b,0xc0\n"
+#define K7_NOP3 ".byte 0x8d,0x04,0x20\n"
+#define K7_NOP4 ".byte 0x8d,0x44,0x20,0x00\n"
+#define K7_NOP5 K7_NOP4 ASM_NOP1
+#define K7_NOP6 ".byte 0x8d,0x80,0,0,0,0\n"
+#define K7_NOP7 ".byte 0x8D,0x04,0x05,0,0,0,0\n"
+#define K7_NOP8 K7_NOP7 ASM_NOP1
+#define P6_NOP1 GENERIC_NOP1
+#define P6_NOP2 ".byte 0x66,0x90\n"
+#define P6_NOP3 ".byte 0x0f,0x1f,0x00\n"
+#define P6_NOP4 ".byte 0x0f,0x1f,0x40,0\n"
+#define P6_NOP5 ".byte 0x0f,0x1f,0x44,0x00,0\n"
+#define P6_NOP6 ".byte 0x66,0x0f,0x1f,0x44,0x00,0\n"
+#define P6_NOP7 ".byte 0x0f,0x1f,0x80,0,0,0,0\n"
+#define P6_NOP8 ".byte 0x0f,0x1f,0x84,0x00,0,0,0,0\n"
+#define ASM_NOP1 GENERIC_NOP1
+#define ASM_NOP2 GENERIC_NOP2
+#define ASM_NOP3 GENERIC_NOP3
+#define ASM_NOP4 GENERIC_NOP4
+#define ASM_NOP5 GENERIC_NOP5
+#define ASM_NOP6 GENERIC_NOP6
+#define ASM_NOP7 GENERIC_NOP7
+#define ASM_NOP8 GENERIC_NOP8
+#define ASM_NOP_MAX 8
+#define ARCH_HAS_PREFETCH
+#define ARCH_HAS_PREFETCH
+#define ARCH_HAS_PREFETCHW
+#define ARCH_HAS_SPINLOCK_PREFETCH
+#define spin_lock_prefetch(x) prefetchw(x)
+
+#define cache_line_size() (boot_cpu_data.x86_cache_alignment)
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/ptrace-abi.h b/libc/kernel/arch-x86/asm/ptrace-abi.h
new file mode 100644
index 0000000..3e6ea08
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/ptrace-abi.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_PTRACE_ABI_H
+#define _ASM_X86_PTRACE_ABI_H
+
+#ifdef __i386__
+
+#define EBX 0
+#define ECX 1
+#define EDX 2
+#define ESI 3
+#define EDI 4
+#define EBP 5
+#define EAX 6
+#define DS 7
+#define ES 8
+#define FS 9
+#define GS 10
+#define ORIG_EAX 11
+#define EIP 12
+#define CS 13
+#define EFL 14
+#define UESP 15
+#define SS 16
+#define FRAME_SIZE 17
+
+#else
+
+#if defined(__ASSEMBLY__) || defined(__FRAME_OFFSETS)
+#define R15 0
+#define R14 8
+#define R13 16
+#define R12 24
+#define RBP 32
+#define RBX 40
+
+#define R11 48
+#define R10 56
+#define R9 64
+#define R8 72
+#define RAX 80
+#define RCX 88
+#define RDX 96
+#define RSI 104
+#define RDI 112
+#define ORIG_RAX 120
+
+#define RIP 128
+#define CS 136
+#define EFLAGS 144
+#define RSP 152
+#define SS 160
+#define ARGOFFSET R11
+#endif
+
+#define FRAME_SIZE 168
+
+#endif
+
+#define PTRACE_GETREGS 12
+#define PTRACE_SETREGS 13
+#define PTRACE_GETFPREGS 14
+#define PTRACE_SETFPREGS 15
+#define PTRACE_GETFPXREGS 18
+#define PTRACE_SETFPXREGS 19
+
+#define PTRACE_OLDSETOPTIONS 21
+
+#define PTRACE_GET_THREAD_AREA 25
+#define PTRACE_SET_THREAD_AREA 26
+
+#ifdef __x86_64__
+#define PTRACE_ARCH_PRCTL 30
+#else
+#define PTRACE_SYSEMU 31
+#define PTRACE_SYSEMU_SINGLESTEP 32
+#endif
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/ptrace.h b/libc/kernel/arch-x86/asm/ptrace.h
new file mode 100644
index 0000000..4743e0f
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/ptrace.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_PTRACE_H
+#define _ASM_X86_PTRACE_H
+
+#include <linux/compiler.h>
+#include <asm/ptrace-abi.h>
+
+#ifndef __ASSEMBLY__
+
+#ifdef __i386__
+
+struct pt_regs {
+ long ebx;
+ long ecx;
+ long edx;
+ long esi;
+ long edi;
+ long ebp;
+ long eax;
+ int xds;
+ int xes;
+ int xfs;
+
+ long orig_eax;
+ long eip;
+ int xcs;
+ long eflags;
+ long esp;
+ int xss;
+};
+
+#else
+
+struct pt_regs {
+ unsigned long r15;
+ unsigned long r14;
+ unsigned long r13;
+ unsigned long r12;
+ unsigned long rbp;
+ unsigned long rbx;
+
+ unsigned long r11;
+ unsigned long r10;
+ unsigned long r9;
+ unsigned long r8;
+ unsigned long rax;
+ unsigned long rcx;
+ unsigned long rdx;
+ unsigned long rsi;
+ unsigned long rdi;
+ unsigned long orig_rax;
+
+ unsigned long rip;
+ unsigned long cs;
+ unsigned long eflags;
+ unsigned long rsp;
+ unsigned long ss;
+
+};
+
+#endif
+#endif
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/required-features.h b/libc/kernel/arch-x86/asm/required-features.h
new file mode 100644
index 0000000..a96517a
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/required-features.h
@@ -0,0 +1,44 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_REQUIRED_FEATURES_H
+#define _ASM_REQUIRED_FEATURES_H 1
+
+#define NEED_FPU (1<<(X86_FEATURE_FPU & 31))
+
+#define NEED_PAE 0
+#define NEED_CX8 0
+
+#define NEED_CMOV 0
+
+#define NEED_3DNOW 0
+
+#define NEED_PSE 0
+#define NEED_MSR 0
+#define NEED_PGE 0
+#define NEED_FXSR 0
+#define NEED_XMM 0
+#define NEED_XMM2 0
+#define NEED_LM 0
+
+#define REQUIRED_MASK0 (NEED_FPU|NEED_PSE|NEED_MSR|NEED_PAE| NEED_CX8|NEED_PGE|NEED_FXSR|NEED_CMOV| NEED_XMM|NEED_XMM2)
+#define SSE_MASK (NEED_XMM|NEED_XMM2)
+
+#define REQUIRED_MASK1 (NEED_LM|NEED_3DNOW)
+
+#define REQUIRED_MASK2 0
+#define REQUIRED_MASK3 0
+#define REQUIRED_MASK4 0
+#define REQUIRED_MASK5 0
+#define REQUIRED_MASK6 0
+#define REQUIRED_MASK7 0
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/resource.h b/libc/kernel/arch-x86/asm/resource.h
new file mode 100644
index 0000000..29d9e12
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/resource.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include <asm-generic/resource.h>
diff --git a/libc/kernel/arch-x86/asm/rwlock.h b/libc/kernel/arch-x86/asm/rwlock.h
new file mode 100644
index 0000000..3693542
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/rwlock.h
@@ -0,0 +1,18 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_RWLOCK_H
+#define _ASM_X86_RWLOCK_H
+
+#define RW_LOCK_BIAS 0x01000000
+#define RW_LOCK_BIAS_STR "0x01000000"
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/scatterlist.h b/libc/kernel/arch-x86/asm/scatterlist.h
new file mode 100644
index 0000000..fa4d0cc
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/scatterlist.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "scatterlist_64.h"
diff --git a/libc/kernel/arch-x86/asm/scatterlist_32.h b/libc/kernel/arch-x86/asm/scatterlist_32.h
new file mode 100644
index 0000000..29044c3
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/scatterlist_32.h
@@ -0,0 +1,31 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _I386_SCATTERLIST_H
+#define _I386_SCATTERLIST_H
+
+#include <asm/types.h>
+
+struct scatterlist {
+ unsigned long page_link;
+ unsigned int offset;
+ dma_addr_t dma_address;
+ unsigned int length;
+};
+
+#define ARCH_HAS_SG_CHAIN
+
+#define sg_dma_address(sg) ((sg)->dma_address)
+#define sg_dma_len(sg) ((sg)->length)
+
+#define ISA_DMA_THRESHOLD (0x00ffffff)
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/sections.h b/libc/kernel/arch-x86/asm/sections.h
new file mode 100644
index 0000000..a21da3e
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/sections.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include <asm-generic/sections.h>
diff --git a/libc/kernel/arch-x86/asm/segment.h b/libc/kernel/arch-x86/asm/segment.h
new file mode 100644
index 0000000..6877a80
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/segment.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "segment_64.h"
diff --git a/libc/kernel/arch-x86/asm/segment_32.h b/libc/kernel/arch-x86/asm/segment_32.h
new file mode 100644
index 0000000..54b312b
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/segment_32.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_SEGMENT_H
+#define _ASM_SEGMENT_H
+
+#define GDT_ENTRY_TLS_ENTRIES 3
+#define GDT_ENTRY_TLS_MIN 6
+#define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
+
+#define TLS_SIZE (GDT_ENTRY_TLS_ENTRIES * 8)
+
+#define GDT_ENTRY_DEFAULT_USER_CS 14
+#define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS * 8 + 3)
+
+#define GDT_ENTRY_DEFAULT_USER_DS 15
+#define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS * 8 + 3)
+
+#define GDT_ENTRY_KERNEL_BASE 12
+
+#define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE + 0)
+#define __KERNEL_CS (GDT_ENTRY_KERNEL_CS * 8)
+
+#define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE + 1)
+#define __KERNEL_DS (GDT_ENTRY_KERNEL_DS * 8)
+
+#define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE + 4)
+#define GDT_ENTRY_LDT (GDT_ENTRY_KERNEL_BASE + 5)
+
+#define GDT_ENTRY_PNPBIOS_BASE (GDT_ENTRY_KERNEL_BASE + 6)
+#define GDT_ENTRY_APMBIOS_BASE (GDT_ENTRY_KERNEL_BASE + 11)
+
+#define GDT_ENTRY_ESPFIX_SS (GDT_ENTRY_KERNEL_BASE + 14)
+#define __ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)
+
+#define GDT_ENTRY_PERCPU (GDT_ENTRY_KERNEL_BASE + 15)
+#define __KERNEL_PERCPU 0
+
+#define GDT_ENTRY_DOUBLEFAULT_TSS 31
+
+#define GDT_ENTRIES 32
+#define GDT_SIZE (GDT_ENTRIES * 8)
+
+#define GDT_ENTRY_BOOT_CS 2
+#define __BOOT_CS (GDT_ENTRY_BOOT_CS * 8)
+
+#define GDT_ENTRY_BOOT_DS (GDT_ENTRY_BOOT_CS + 1)
+#define __BOOT_DS (GDT_ENTRY_BOOT_DS * 8)
+
+#define GDT_ENTRY_PNPBIOS_CS32 (GDT_ENTRY_PNPBIOS_BASE + 0)
+#define GDT_ENTRY_PNPBIOS_CS16 (GDT_ENTRY_PNPBIOS_BASE + 1)
+#define GDT_ENTRY_PNPBIOS_DS (GDT_ENTRY_PNPBIOS_BASE + 2)
+#define GDT_ENTRY_PNPBIOS_TS1 (GDT_ENTRY_PNPBIOS_BASE + 3)
+#define GDT_ENTRY_PNPBIOS_TS2 (GDT_ENTRY_PNPBIOS_BASE + 4)
+
+#define PNP_CS32 (GDT_ENTRY_PNPBIOS_CS32 * 8)
+#define PNP_CS16 (GDT_ENTRY_PNPBIOS_CS16 * 8)
+#define PNP_DS (GDT_ENTRY_PNPBIOS_DS * 8)
+#define PNP_TS1 (GDT_ENTRY_PNPBIOS_TS1 * 8)
+#define PNP_TS2 (GDT_ENTRY_PNPBIOS_TS2 * 8)
+
+#define IDT_ENTRIES 256
+
+#define SEGMENT_RPL_MASK 0x3
+
+#define SEGMENT_TI_MASK 0x4
+
+#define USER_RPL 0x3
+
+#define SEGMENT_LDT 0x4
+#define SEGMENT_GDT 0x0
+
+#define get_kernel_rpl() 0
+
+#define SEGMENT_IS_KERNEL_CODE(x) (((x) & 0xfc) == GDT_ENTRY_KERNEL_CS * 8)
+
+#define SEGMENT_IS_FLAT_CODE(x) (((x) & 0xec) == GDT_ENTRY_KERNEL_CS * 8)
+
+#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/semaphore.h b/libc/kernel/arch-x86/asm/semaphore.h
new file mode 100644
index 0000000..8b4c595
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/semaphore.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "semaphore_64.h"
diff --git a/libc/kernel/arch-x86/asm/semaphore_32.h b/libc/kernel/arch-x86/asm/semaphore_32.h
new file mode 100644
index 0000000..babe779
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/semaphore_32.h
@@ -0,0 +1,17 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _I386_SEMAPHORE_H
+#define _I386_SEMAPHORE_H
+
+#include <linux/linkage.h>
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/sembuf.h b/libc/kernel/arch-x86/asm/sembuf.h
new file mode 100644
index 0000000..1695208
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/sembuf.h
@@ -0,0 +1,26 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_SEMBUF_H
+#define _ASM_X86_SEMBUF_H
+
+struct semid64_ds {
+ struct ipc64_perm sem_perm;
+ __kernel_time_t sem_otime;
+ unsigned long __unused1;
+ __kernel_time_t sem_ctime;
+ unsigned long __unused2;
+ unsigned long sem_nsems;
+ unsigned long __unused3;
+ unsigned long __unused4;
+};
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/setup.h b/libc/kernel/arch-x86/asm/setup.h
new file mode 100644
index 0000000..696ed97
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/setup.h
@@ -0,0 +1,17 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_SETUP_H
+#define _ASM_X86_SETUP_H
+
+#define COMMAND_LINE_SIZE 2048
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/shmbuf.h b/libc/kernel/arch-x86/asm/shmbuf.h
new file mode 100644
index 0000000..314ccb7
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/shmbuf.h
@@ -0,0 +1,49 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_SHMBUF_H
+#define _ASM_X86_SHMBUF_H
+
+struct shmid64_ds {
+ struct ipc64_perm shm_perm;
+ size_t shm_segsz;
+ __kernel_time_t shm_atime;
+#ifdef __i386__
+ unsigned long __unused1;
+#endif
+ __kernel_time_t shm_dtime;
+#ifdef __i386__
+ unsigned long __unused2;
+#endif
+ __kernel_time_t shm_ctime;
+#ifdef __i386__
+ unsigned long __unused3;
+#endif
+ __kernel_pid_t shm_cpid;
+ __kernel_pid_t shm_lpid;
+ unsigned long shm_nattch;
+ unsigned long __unused4;
+ unsigned long __unused5;
+};
+
+struct shminfo64 {
+ unsigned long shmmax;
+ unsigned long shmmin;
+ unsigned long shmmni;
+ unsigned long shmseg;
+ unsigned long shmall;
+ unsigned long __unused1;
+ unsigned long __unused2;
+ unsigned long __unused3;
+ unsigned long __unused4;
+};
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/shmparam.h b/libc/kernel/arch-x86/asm/shmparam.h
new file mode 100644
index 0000000..e667ba1
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/shmparam.h
@@ -0,0 +1,17 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_SHMPARAM_H
+#define _ASM_X86_SHMPARAM_H
+
+#define SHMLBA PAGE_SIZE
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/sigcontext.h b/libc/kernel/arch-x86/asm/sigcontext.h
new file mode 100644
index 0000000..a8f76f0
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/sigcontext.h
@@ -0,0 +1,132 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_SIGCONTEXT_H
+#define _ASM_X86_SIGCONTEXT_H
+
+#include <linux/compiler.h>
+#include <asm/types.h>
+
+#ifdef __i386__
+
+struct _fpreg {
+ unsigned short significand[4];
+ unsigned short exponent;
+};
+
+struct _fpxreg {
+ unsigned short significand[4];
+ unsigned short exponent;
+ unsigned short padding[3];
+};
+
+struct _xmmreg {
+ unsigned long element[4];
+};
+
+struct _fpstate {
+
+ unsigned long cw;
+ unsigned long sw;
+ unsigned long tag;
+ unsigned long ipoff;
+ unsigned long cssel;
+ unsigned long dataoff;
+ unsigned long datasel;
+ struct _fpreg _st[8];
+ unsigned short status;
+ unsigned short magic;
+
+ unsigned long _fxsr_env[6];
+ unsigned long mxcsr;
+ unsigned long reserved;
+ struct _fpxreg _fxsr_st[8];
+ struct _xmmreg _xmm[8];
+ unsigned long padding[56];
+};
+
+#define X86_FXSR_MAGIC 0x0000
+
+struct sigcontext {
+ unsigned short gs, __gsh;
+ unsigned short fs, __fsh;
+ unsigned short es, __esh;
+ unsigned short ds, __dsh;
+ unsigned long edi;
+ unsigned long esi;
+ unsigned long ebp;
+ unsigned long esp;
+ unsigned long ebx;
+ unsigned long edx;
+ unsigned long ecx;
+ unsigned long eax;
+ unsigned long trapno;
+ unsigned long err;
+ unsigned long eip;
+ unsigned short cs, __csh;
+ unsigned long eflags;
+ unsigned long esp_at_signal;
+ unsigned short ss, __ssh;
+ struct _fpstate __user * fpstate;
+ unsigned long oldmask;
+ unsigned long cr2;
+};
+
+#else
+
+struct _fpstate {
+ __u16 cwd;
+ __u16 swd;
+ __u16 twd;
+ __u16 fop;
+ __u64 rip;
+ __u64 rdp;
+ __u32 mxcsr;
+ __u32 mxcsr_mask;
+ __u32 st_space[32];
+ __u32 xmm_space[64];
+ __u32 reserved2[24];
+};
+
+struct sigcontext {
+ unsigned long r8;
+ unsigned long r9;
+ unsigned long r10;
+ unsigned long r11;
+ unsigned long r12;
+ unsigned long r13;
+ unsigned long r14;
+ unsigned long r15;
+ unsigned long rdi;
+ unsigned long rsi;
+ unsigned long rbp;
+ unsigned long rbx;
+ unsigned long rdx;
+ unsigned long rax;
+ unsigned long rcx;
+ unsigned long rsp;
+ unsigned long rip;
+ unsigned long eflags;
+ unsigned short cs;
+ unsigned short gs;
+ unsigned short fs;
+ unsigned short __pad0;
+ unsigned long err;
+ unsigned long trapno;
+ unsigned long oldmask;
+ unsigned long cr2;
+ struct _fpstate __user *fpstate;
+ unsigned long reserved1[8];
+};
+
+#endif
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/siginfo.h b/libc/kernel/arch-x86/asm/siginfo.h
new file mode 100644
index 0000000..0d21d22
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/siginfo.h
@@ -0,0 +1,21 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_SIGINFO_H
+#define _ASM_X86_SIGINFO_H
+
+#ifdef __x86_64__
+#define __ARCH_SI_PREAMBLE_SIZE (4 * sizeof(int))
+#endif
+
+#include <asm-generic/siginfo.h>
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/signal.h b/libc/kernel/arch-x86/asm/signal.h
new file mode 100644
index 0000000..6d84eab
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/signal.h
@@ -0,0 +1,127 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_SIGNAL_H
+#define _ASM_X86_SIGNAL_H
+
+#ifndef __ASSEMBLY__
+#include <linux/types.h>
+#include <linux/time.h>
+#include <linux/compiler.h>
+
+struct siginfo;
+
+#define NSIG 32
+typedef unsigned long sigset_t;
+
+#endif
+
+#define SIGHUP 1
+#define SIGINT 2
+#define SIGQUIT 3
+#define SIGILL 4
+#define SIGTRAP 5
+#define SIGABRT 6
+#define SIGIOT 6
+#define SIGBUS 7
+#define SIGFPE 8
+#define SIGKILL 9
+#define SIGUSR1 10
+#define SIGSEGV 11
+#define SIGUSR2 12
+#define SIGPIPE 13
+#define SIGALRM 14
+#define SIGTERM 15
+#define SIGSTKFLT 16
+#define SIGCHLD 17
+#define SIGCONT 18
+#define SIGSTOP 19
+#define SIGTSTP 20
+#define SIGTTIN 21
+#define SIGTTOU 22
+#define SIGURG 23
+#define SIGXCPU 24
+#define SIGXFSZ 25
+#define SIGVTALRM 26
+#define SIGPROF 27
+#define SIGWINCH 28
+#define SIGIO 29
+#define SIGPOLL SIGIO
+
+#define SIGPWR 30
+#define SIGSYS 31
+#define SIGUNUSED 31
+
+#define SIGRTMIN 32
+#define SIGRTMAX _NSIG
+
+#define SA_NOCLDSTOP 0x00000001u
+#define SA_NOCLDWAIT 0x00000002u
+#define SA_SIGINFO 0x00000004u
+#define SA_ONSTACK 0x08000000u
+#define SA_RESTART 0x10000000u
+#define SA_NODEFER 0x40000000u
+#define SA_RESETHAND 0x80000000u
+
+#define SA_NOMASK SA_NODEFER
+#define SA_ONESHOT SA_RESETHAND
+
+#define SA_RESTORER 0x04000000
+
+#define SS_ONSTACK 1
+#define SS_DISABLE 2
+
+#define MINSIGSTKSZ 2048
+#define SIGSTKSZ 8192
+
+#include <asm-generic/signal.h>
+
+#ifndef __ASSEMBLY__
+
+#ifdef __i386__
+
+struct sigaction {
+ union {
+ __sighandler_t _sa_handler;
+ void (*_sa_sigaction)(int, struct siginfo *, void *);
+ } _u;
+ sigset_t sa_mask;
+ unsigned long sa_flags;
+ void (*sa_restorer)(void);
+};
+
+#define sa_handler _u._sa_handler
+#define sa_sigaction _u._sa_sigaction
+
+#else
+
+struct sigaction {
+ __sighandler_t sa_handler;
+ unsigned long sa_flags;
+ __sigrestore_t sa_restorer;
+ sigset_t sa_mask;
+};
+
+struct k_sigaction {
+ struct sigaction sa;
+};
+
+#endif
+
+typedef struct sigaltstack {
+ void __user *ss_sp;
+ int ss_flags;
+ size_t ss_size;
+} stack_t;
+
+#endif
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/smp.h b/libc/kernel/arch-x86/asm/smp.h
new file mode 100644
index 0000000..40d4601
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/smp.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "smp_64.h"
diff --git a/libc/kernel/arch-x86/asm/smp_32.h b/libc/kernel/arch-x86/asm/smp_32.h
new file mode 100644
index 0000000..f093a24
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/smp_32.h
@@ -0,0 +1,34 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_SMP_H
+#define __ASM_SMP_H
+
+#ifndef __ASSEMBLY__
+#include <linux/kernel.h>
+#include <linux/threads.h>
+#include <linux/cpumask.h>
+#endif
+
+#define BAD_APICID 0xFFu
+
+#define safe_smp_processor_id() 0
+#define cpu_physical_id(cpu) boot_cpu_physical_apicid
+
+#define NO_PROC_ID 0xFF
+
+#ifndef __ASSEMBLY__
+
+#define hard_smp_processor_id() 0
+
+#endif
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/socket.h b/libc/kernel/arch-x86/asm/socket.h
new file mode 100644
index 0000000..27d243f
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/socket.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_SOCKET_H
+#define _ASM_SOCKET_H
+
+#include <asm/sockios.h>
+
+#define SOL_SOCKET 1
+
+#define SO_DEBUG 1
+#define SO_REUSEADDR 2
+#define SO_TYPE 3
+#define SO_ERROR 4
+#define SO_DONTROUTE 5
+#define SO_BROADCAST 6
+#define SO_SNDBUF 7
+#define SO_RCVBUF 8
+#define SO_SNDBUFFORCE 32
+#define SO_RCVBUFFORCE 33
+#define SO_KEEPALIVE 9
+#define SO_OOBINLINE 10
+#define SO_NO_CHECK 11
+#define SO_PRIORITY 12
+#define SO_LINGER 13
+#define SO_BSDCOMPAT 14
+
+#define SO_PASSCRED 16
+#define SO_PEERCRED 17
+#define SO_RCVLOWAT 18
+#define SO_SNDLOWAT 19
+#define SO_RCVTIMEO 20
+#define SO_SNDTIMEO 21
+
+#define SO_SECURITY_AUTHENTICATION 22
+#define SO_SECURITY_ENCRYPTION_TRANSPORT 23
+#define SO_SECURITY_ENCRYPTION_NETWORK 24
+
+#define SO_BINDTODEVICE 25
+
+#define SO_ATTACH_FILTER 26
+#define SO_DETACH_FILTER 27
+
+#define SO_PEERNAME 28
+#define SO_TIMESTAMP 29
+#define SCM_TIMESTAMP SO_TIMESTAMP
+
+#define SO_ACCEPTCONN 30
+
+#define SO_PEERSEC 31
+#define SO_PASSSEC 34
+#define SO_TIMESTAMPNS 35
+#define SCM_TIMESTAMPNS SO_TIMESTAMPNS
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/sockios.h b/libc/kernel/arch-x86/asm/sockios.h
new file mode 100644
index 0000000..ebdfa98
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/sockios.h
@@ -0,0 +1,23 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_SOCKIOS_H
+#define _ASM_X86_SOCKIOS_H
+
+#define FIOSETOWN 0x8901
+#define SIOCSPGRP 0x8902
+#define FIOGETOWN 0x8903
+#define SIOCGPGRP 0x8904
+#define SIOCATMARK 0x8905
+#define SIOCGSTAMP 0x8906
+#define SIOCGSTAMPNS 0x8907
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/spinlock.h b/libc/kernel/arch-x86/asm/spinlock.h
new file mode 100644
index 0000000..10d123a
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/spinlock.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "spinlock_64.h"
diff --git a/libc/kernel/arch-x86/asm/spinlock_32.h b/libc/kernel/arch-x86/asm/spinlock_32.h
new file mode 100644
index 0000000..171783e
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/spinlock_32.h
@@ -0,0 +1,29 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_SPINLOCK_H
+#define __ASM_SPINLOCK_H
+
+#include <asm/atomic.h>
+#include <asm/rwlock.h>
+#include <asm/page.h>
+#include <asm/processor.h>
+#include <linux/compiler.h>
+
+#define CLI_STRING "cli"
+#define STI_STRING "sti"
+#define CLI_STI_CLOBBERS
+#define CLI_STI_INPUT_ARGS
+
+#define _raw_spin_relax(lock) cpu_relax()
+#define _raw_read_relax(lock) cpu_relax()
+#define _raw_write_relax(lock) cpu_relax()
+#endif
diff --git a/libc/kernel/arch-x86/asm/spinlock_types.h b/libc/kernel/arch-x86/asm/spinlock_types.h
new file mode 100644
index 0000000..ab914c4
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/spinlock_types.h
@@ -0,0 +1,31 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_SPINLOCK_TYPES_H
+#define __ASM_SPINLOCK_TYPES_H
+
+#ifndef __LINUX_SPINLOCK_TYPES_H
+#error "please don't include this file directly"
+#endif
+
+typedef struct {
+ unsigned int slock;
+} raw_spinlock_t;
+
+#define __RAW_SPIN_LOCK_UNLOCKED { 1 }
+
+typedef struct {
+ unsigned int lock;
+} raw_rwlock_t;
+
+#define __RAW_RW_LOCK_UNLOCKED { RW_LOCK_BIAS }
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/stat.h b/libc/kernel/arch-x86/asm/stat.h
new file mode 100644
index 0000000..837d716
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/stat.h
@@ -0,0 +1,120 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_STAT_H
+#define _ASM_X86_STAT_H
+
+#define STAT_HAVE_NSEC 1
+
+#ifdef __i386__
+struct stat {
+ unsigned long st_dev;
+ unsigned long st_ino;
+ unsigned short st_mode;
+ unsigned short st_nlink;
+ unsigned short st_uid;
+ unsigned short st_gid;
+ unsigned long st_rdev;
+ unsigned long st_size;
+ unsigned long st_blksize;
+ unsigned long st_blocks;
+ unsigned long st_atime;
+ unsigned long st_atime_nsec;
+ unsigned long st_mtime;
+ unsigned long st_mtime_nsec;
+ unsigned long st_ctime;
+ unsigned long st_ctime_nsec;
+ unsigned long __unused4;
+ unsigned long __unused5;
+};
+
+#define STAT64_HAS_BROKEN_ST_INO 1
+
+struct stat64 {
+ unsigned long long st_dev;
+ unsigned char __pad0[4];
+
+ unsigned long __st_ino;
+
+ unsigned int st_mode;
+ unsigned int st_nlink;
+
+ unsigned long st_uid;
+ unsigned long st_gid;
+
+ unsigned long long st_rdev;
+ unsigned char __pad3[4];
+
+ long long st_size;
+ unsigned long st_blksize;
+
+ unsigned long long st_blocks;
+
+ unsigned long st_atime;
+ unsigned long st_atime_nsec;
+
+ unsigned long st_mtime;
+ unsigned int st_mtime_nsec;
+
+ unsigned long st_ctime;
+ unsigned long st_ctime_nsec;
+
+ unsigned long long st_ino;
+};
+
+#else
+
+struct stat {
+ unsigned long st_dev;
+ unsigned long st_ino;
+ unsigned long st_nlink;
+
+ unsigned int st_mode;
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned int __pad0;
+ unsigned long st_rdev;
+ long st_size;
+ long st_blksize;
+ long st_blocks;
+
+ unsigned long st_atime;
+ unsigned long st_atime_nsec;
+ unsigned long st_mtime;
+ unsigned long st_mtime_nsec;
+ unsigned long st_ctime;
+ unsigned long st_ctime_nsec;
+ long __unused[3];
+};
+#endif
+
+struct __old_kernel_stat {
+ unsigned short st_dev;
+ unsigned short st_ino;
+ unsigned short st_mode;
+ unsigned short st_nlink;
+ unsigned short st_uid;
+ unsigned short st_gid;
+ unsigned short st_rdev;
+#ifdef __i386__
+ unsigned long st_size;
+ unsigned long st_atime;
+ unsigned long st_mtime;
+ unsigned long st_ctime;
+#else
+ unsigned int st_size;
+ unsigned int st_atime;
+ unsigned int st_mtime;
+ unsigned int st_ctime;
+#endif
+};
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/statfs.h b/libc/kernel/arch-x86/asm/statfs.h
new file mode 100644
index 0000000..592d864
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/statfs.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_STATFS_H
+#define _ASM_X86_STATFS_H
+
+#ifdef __i386__
+#include <asm-generic/statfs.h>
+#else
+
+struct statfs {
+ long f_type;
+ long f_bsize;
+ long f_blocks;
+ long f_bfree;
+ long f_bavail;
+ long f_files;
+ long f_ffree;
+ __kernel_fsid_t f_fsid;
+ long f_namelen;
+ long f_frsize;
+ long f_spare[5];
+};
+
+struct statfs64 {
+ long f_type;
+ long f_bsize;
+ long f_blocks;
+ long f_bfree;
+ long f_bavail;
+ long f_files;
+ long f_ffree;
+ __kernel_fsid_t f_fsid;
+ long f_namelen;
+ long f_frsize;
+ long f_spare[5];
+};
+
+struct compat_statfs64 {
+ __u32 f_type;
+ __u32 f_bsize;
+ __u64 f_blocks;
+ __u64 f_bfree;
+ __u64 f_bavail;
+ __u64 f_files;
+ __u64 f_ffree;
+ __kernel_fsid_t f_fsid;
+ __u32 f_namelen;
+ __u32 f_frsize;
+ __u32 f_spare[5];
+} __attribute__((packed));
+
+#endif
+#endif
diff --git a/libc/kernel/arch-x86/asm/string.h b/libc/kernel/arch-x86/asm/string.h
new file mode 100644
index 0000000..92fa291
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/string.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "string_64.h"
diff --git a/libc/kernel/arch-x86/asm/string_32.h b/libc/kernel/arch-x86/asm/string_32.h
new file mode 100644
index 0000000..58a72d7
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/string_32.h
@@ -0,0 +1,15 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _I386_STRING_H_
+#define _I386_STRING_H_
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/swiotlb.h b/libc/kernel/arch-x86/asm/swiotlb.h
new file mode 100644
index 0000000..5ee37b3
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/swiotlb.h
@@ -0,0 +1,19 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_SWIOTLB_H
+#define _ASM_SWIOTLB_H 1
+
+#include <asm/dma-mapping.h>
+
+#define swiotlb 0
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/system.h b/libc/kernel/arch-x86/asm/system.h
new file mode 100644
index 0000000..834193b
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/system.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "system_64.h"
diff --git a/libc/kernel/arch-x86/asm/system_32.h b/libc/kernel/arch-x86/asm/system_32.h
new file mode 100644
index 0000000..d799ae6
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/system_32.h
@@ -0,0 +1,33 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_SYSTEM_H
+#define __ASM_SYSTEM_H
+
+#include <linux/kernel.h>
+#include <asm/segment.h>
+#include <asm/cpufeature.h>
+#include <asm/cmpxchg.h>
+
+#define nop() __asm__ __volatile__ ("nop")
+#define mb() alternative("lock; addl $0,0(%%esp)", "mfence", X86_FEATURE_XMM2)
+#define rmb() alternative("lock; addl $0,0(%%esp)", "lfence", X86_FEATURE_XMM2)
+#define wmb() alternative("lock; addl $0,0(%%esp)", "sfence", X86_FEATURE_XMM)
+#define read_barrier_depends() do { } while(0)
+#define smp_mb() barrier()
+#define smp_rmb() barrier()
+#define smp_wmb() barrier()
+#define smp_read_barrier_depends() do { } while(0)
+#define set_mb(var, value) do { var = value; barrier(); } while (0)
+#include <linux/irqflags.h>
+#define HAVE_DISABLE_HLT
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/termbits.h b/libc/kernel/arch-x86/asm/termbits.h
new file mode 100644
index 0000000..6d7c5e8
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/termbits.h
@@ -0,0 +1,201 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_TERMBITS_H
+#define _ASM_X86_TERMBITS_H
+
+#include <linux/posix_types.h>
+
+typedef unsigned char cc_t;
+typedef unsigned int speed_t;
+typedef unsigned int tcflag_t;
+
+#define NCCS 19
+struct termios {
+ tcflag_t c_iflag;
+ tcflag_t c_oflag;
+ tcflag_t c_cflag;
+ tcflag_t c_lflag;
+ cc_t c_line;
+ cc_t c_cc[NCCS];
+};
+
+struct termios2 {
+ tcflag_t c_iflag;
+ tcflag_t c_oflag;
+ tcflag_t c_cflag;
+ tcflag_t c_lflag;
+ cc_t c_line;
+ cc_t c_cc[NCCS];
+ speed_t c_ispeed;
+ speed_t c_ospeed;
+};
+
+struct ktermios {
+ tcflag_t c_iflag;
+ tcflag_t c_oflag;
+ tcflag_t c_cflag;
+ tcflag_t c_lflag;
+ cc_t c_line;
+ cc_t c_cc[NCCS];
+ speed_t c_ispeed;
+ speed_t c_ospeed;
+};
+
+#define VINTR 0
+#define VQUIT 1
+#define VERASE 2
+#define VKILL 3
+#define VEOF 4
+#define VTIME 5
+#define VMIN 6
+#define VSWTC 7
+#define VSTART 8
+#define VSTOP 9
+#define VSUSP 10
+#define VEOL 11
+#define VREPRINT 12
+#define VDISCARD 13
+#define VWERASE 14
+#define VLNEXT 15
+#define VEOL2 16
+
+#define IGNBRK 0000001
+#define BRKINT 0000002
+#define IGNPAR 0000004
+#define PARMRK 0000010
+#define INPCK 0000020
+#define ISTRIP 0000040
+#define INLCR 0000100
+#define IGNCR 0000200
+#define ICRNL 0000400
+#define IUCLC 0001000
+#define IXON 0002000
+#define IXANY 0004000
+#define IXOFF 0010000
+#define IMAXBEL 0020000
+#define IUTF8 0040000
+
+#define OPOST 0000001
+#define OLCUC 0000002
+#define ONLCR 0000004
+#define OCRNL 0000010
+#define ONOCR 0000020
+#define ONLRET 0000040
+#define OFILL 0000100
+#define OFDEL 0000200
+#define NLDLY 0000400
+#define NL0 0000000
+#define NL1 0000400
+#define CRDLY 0003000
+#define CR0 0000000
+#define CR1 0001000
+#define CR2 0002000
+#define CR3 0003000
+#define TABDLY 0014000
+#define TAB0 0000000
+#define TAB1 0004000
+#define TAB2 0010000
+#define TAB3 0014000
+#define XTABS 0014000
+#define BSDLY 0020000
+#define BS0 0000000
+#define BS1 0020000
+#define VTDLY 0040000
+#define VT0 0000000
+#define VT1 0040000
+#define FFDLY 0100000
+#define FF0 0000000
+#define FF1 0100000
+
+#define CBAUD 0010017
+#define B0 0000000
+#define B50 0000001
+#define B75 0000002
+#define B110 0000003
+#define B134 0000004
+#define B150 0000005
+#define B200 0000006
+#define B300 0000007
+#define B600 0000010
+#define B1200 0000011
+#define B1800 0000012
+#define B2400 0000013
+#define B4800 0000014
+#define B9600 0000015
+#define B19200 0000016
+#define B38400 0000017
+#define EXTA B19200
+#define EXTB B38400
+#define CSIZE 0000060
+#define CS5 0000000
+#define CS6 0000020
+#define CS7 0000040
+#define CS8 0000060
+#define CSTOPB 0000100
+#define CREAD 0000200
+#define PARENB 0000400
+#define PARODD 0001000
+#define HUPCL 0002000
+#define CLOCAL 0004000
+#define CBAUDEX 0010000
+#define BOTHER 0010000
+#define B57600 0010001
+#define B115200 0010002
+#define B230400 0010003
+#define B460800 0010004
+#define B500000 0010005
+#define B576000 0010006
+#define B921600 0010007
+#define B1000000 0010010
+#define B1152000 0010011
+#define B1500000 0010012
+#define B2000000 0010013
+#define B2500000 0010014
+#define B3000000 0010015
+#define B3500000 0010016
+#define B4000000 0010017
+#define CIBAUD 002003600000
+#define CMSPAR 010000000000
+#define CRTSCTS 020000000000
+
+#define IBSHIFT 16
+
+#define ISIG 0000001
+#define ICANON 0000002
+#define XCASE 0000004
+#define ECHO 0000010
+#define ECHOE 0000020
+#define ECHOK 0000040
+#define ECHONL 0000100
+#define NOFLSH 0000200
+#define TOSTOP 0000400
+#define ECHOCTL 0001000
+#define ECHOPRT 0002000
+#define ECHOKE 0004000
+#define FLUSHO 0010000
+#define PENDIN 0040000
+#define IEXTEN 0100000
+
+#define TCOOFF 0
+#define TCOON 1
+#define TCIOFF 2
+#define TCION 3
+
+#define TCIFLUSH 0
+#define TCOFLUSH 1
+#define TCIOFLUSH 2
+
+#define TCSANOW 0
+#define TCSADRAIN 1
+#define TCSAFLUSH 2
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/termios.h b/libc/kernel/arch-x86/asm/termios.h
new file mode 100644
index 0000000..4a38aee
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/termios.h
@@ -0,0 +1,50 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_TERMIOS_H
+#define _ASM_X86_TERMIOS_H
+
+#include <asm/termbits.h>
+#include <asm/ioctls.h>
+
+struct winsize {
+ unsigned short ws_row;
+ unsigned short ws_col;
+ unsigned short ws_xpixel;
+ unsigned short ws_ypixel;
+};
+
+#define NCC 8
+struct termio {
+ unsigned short c_iflag;
+ unsigned short c_oflag;
+ unsigned short c_cflag;
+ unsigned short c_lflag;
+ unsigned char c_line;
+ unsigned char c_cc[NCC];
+};
+
+#define TIOCM_LE 0x001
+#define TIOCM_DTR 0x002
+#define TIOCM_RTS 0x004
+#define TIOCM_ST 0x008
+#define TIOCM_SR 0x010
+#define TIOCM_CTS 0x020
+#define TIOCM_CAR 0x040
+#define TIOCM_RNG 0x080
+#define TIOCM_DSR 0x100
+#define TIOCM_CD TIOCM_CAR
+#define TIOCM_RI TIOCM_RNG
+#define TIOCM_OUT1 0x2000
+#define TIOCM_OUT2 0x4000
+#define TIOCM_LOOP 0x8000
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/thread_info.h b/libc/kernel/arch-x86/asm/thread_info.h
new file mode 100644
index 0000000..ff46b08
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/thread_info.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "thread_info_64.h"
diff --git a/libc/kernel/arch-x86/asm/thread_info_32.h b/libc/kernel/arch-x86/asm/thread_info_32.h
new file mode 100644
index 0000000..5664ef8
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/thread_info_32.h
@@ -0,0 +1,15 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_THREAD_INFO_H
+#define _ASM_THREAD_INFO_H
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/tlbflush.h b/libc/kernel/arch-x86/asm/tlbflush.h
new file mode 100644
index 0000000..fd6b226
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/tlbflush.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "tlbflush_64.h"
diff --git a/libc/kernel/arch-x86/asm/tlbflush_32.h b/libc/kernel/arch-x86/asm/tlbflush_32.h
new file mode 100644
index 0000000..8ebff80
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/tlbflush_32.h
@@ -0,0 +1,43 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _I386_TLBFLUSH_H
+#define _I386_TLBFLUSH_H
+
+#include <linux/mm.h>
+#include <asm/processor.h>
+
+#define __flush_tlb() __native_flush_tlb()
+#define __flush_tlb_global() __native_flush_tlb_global()
+#define __flush_tlb_single(addr) __native_flush_tlb_single(addr)
+
+#define __native_flush_tlb() do { unsigned int tmpreg; __asm__ __volatile__( "movl %%cr3, %0; \n" "movl %0, %%cr3; # flush TLB \n" : "=r" (tmpreg) :: "memory"); } while (0)
+
+#define __native_flush_tlb_global() do { unsigned int tmpreg, cr4, cr4_orig; __asm__ __volatile__( "movl %%cr4, %2; # turn off PGE \n" "movl %2, %1; \n" "andl %3, %1; \n" "movl %1, %%cr4; \n" "movl %%cr3, %0; \n" "movl %0, %%cr3; # flush TLB \n" "movl %2, %%cr4; # turn PGE back on \n" : "=&r" (tmpreg), "=&r" (cr4), "=&r" (cr4_orig) : "i" (~X86_CR4_PGE) : "memory"); } while (0)
+
+#define __native_flush_tlb_single(addr) __asm__ __volatile__("invlpg (%0)" ::"r" (addr) : "memory")
+
+#define __flush_tlb_all() do { if (cpu_has_pge) __flush_tlb_global(); else __flush_tlb(); } while (0)
+
+#define cpu_has_invlpg (boot_cpu_data.x86 > 3)
+
+#define __flush_tlb_one(addr) do { if (cpu_has_invlpg) __flush_tlb_single(addr); else __flush_tlb(); } while (0)
+
+#define TLB_FLUSH_ALL 0xffffffff
+
+#include <linux/sched.h>
+
+#define flush_tlb() __flush_tlb()
+#define flush_tlb_all() __flush_tlb_all()
+#define local_flush_tlb() __flush_tlb()
+
+#define flush_tlb_others(mask, mm, va) native_flush_tlb_others(&mask, mm, va)
+#endif
diff --git a/libc/kernel/arch-x86/asm/tsc.h b/libc/kernel/arch-x86/asm/tsc.h
new file mode 100644
index 0000000..2528cd1
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/tsc.h
@@ -0,0 +1,22 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_TSC_H
+#define _ASM_X86_TSC_H
+
+#include <asm/processor.h>
+
+#define NS_SCALE 10
+#define US_SCALE 32
+
+typedef unsigned long long cycles_t;
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/types.h b/libc/kernel/arch-x86/asm/types.h
new file mode 100644
index 0000000..4af92b0
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/types.h
@@ -0,0 +1,40 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_TYPES_H
+#define _ASM_X86_TYPES_H
+
+#ifndef __ASSEMBLY__
+
+typedef unsigned short umode_t;
+
+typedef __signed__ char __s8;
+typedef unsigned char __u8;
+
+typedef __signed__ short __s16;
+typedef unsigned short __u16;
+
+typedef __signed__ int __s32;
+typedef unsigned int __u32;
+
+#ifdef __i386__
+#ifdef __GNUC__
+__extension__ typedef __signed__ long long __s64;
+__extension__ typedef unsigned long long __u64;
+#endif
+#else
+typedef __signed__ long long __s64;
+typedef unsigned long long __u64;
+#endif
+
+#endif
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/uaccess.h b/libc/kernel/arch-x86/asm/uaccess.h
new file mode 100644
index 0000000..b2bec69
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/uaccess.h
@@ -0,0 +1,12 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#include "uaccess_64.h"
diff --git a/libc/kernel/arch-x86/asm/uaccess_32.h b/libc/kernel/arch-x86/asm/uaccess_32.h
new file mode 100644
index 0000000..9827fc4
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/uaccess_32.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __i386_UACCESS_H
+#define __i386_UACCESS_H
+
+#include <linux/errno.h>
+#include <linux/thread_info.h>
+#include <linux/prefetch.h>
+#include <linux/string.h>
+#include <asm/page.h>
+
+#define VERIFY_READ 0
+#define VERIFY_WRITE 1
+
+#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
+
+#define KERNEL_DS MAKE_MM_SEG(0xFFFFFFFFUL)
+#define USER_DS MAKE_MM_SEG(PAGE_OFFSET)
+
+#define get_ds() (KERNEL_DS)
+#define get_fs() (current_thread_info()->addr_limit)
+#define set_fs(x) (current_thread_info()->addr_limit = (x))
+
+#define segment_eq(a,b) ((a).seg == (b).seg)
+
+#define __addr_ok(addr) ((unsigned long __force)(addr) < (current_thread_info()->addr_limit.seg))
+
+#define __range_ok(addr,size) ({ unsigned long flag,roksum; __chk_user_ptr(addr); asm("addl %3,%1 ; sbbl %0,%0; cmpl %1,%4; sbbl $0,%0" :"=&r" (flag), "=r" (roksum) :"1" (addr),"g" ((int)(size)),"rm" (current_thread_info()->addr_limit.seg)); flag; })
+
+#define access_ok(type,addr,size) (likely(__range_ok(addr,size) == 0))
+
+struct exception_table_entry
+{
+ unsigned long insn, fixup;
+};
+
+#define __get_user_x(size,ret,x,ptr) __asm__ __volatile__("call __get_user_" #size :"=a" (ret),"=d" (x) :"0" (ptr))
+
+#define get_user(x,ptr) ({ int __ret_gu; unsigned long __val_gu; __chk_user_ptr(ptr); switch(sizeof (*(ptr))) { case 1: __get_user_x(1,__ret_gu,__val_gu,ptr); break; case 2: __get_user_x(2,__ret_gu,__val_gu,ptr); break; case 4: __get_user_x(4,__ret_gu,__val_gu,ptr); break; default: __get_user_x(X,__ret_gu,__val_gu,ptr); break; } (x) = (__typeof__(*(ptr)))__val_gu; __ret_gu; })
+
+#define __put_user_1(x, ptr) __asm__ __volatile__("call __put_user_1":"=a" (__ret_pu):"0" ((typeof(*(ptr)))(x)), "c" (ptr))
+#define __put_user_2(x, ptr) __asm__ __volatile__("call __put_user_2":"=a" (__ret_pu):"0" ((typeof(*(ptr)))(x)), "c" (ptr))
+#define __put_user_4(x, ptr) __asm__ __volatile__("call __put_user_4":"=a" (__ret_pu):"0" ((typeof(*(ptr)))(x)), "c" (ptr))
+#define __put_user_8(x, ptr) __asm__ __volatile__("call __put_user_8":"=a" (__ret_pu):"A" ((typeof(*(ptr)))(x)), "c" (ptr))
+#define __put_user_X(x, ptr) __asm__ __volatile__("call __put_user_X":"=a" (__ret_pu):"c" (ptr))
+
+#define put_user(x,ptr) ({ int __ret_pu; __typeof__(*(ptr)) __pus_tmp = x; __ret_pu=0; if(unlikely(__copy_to_user_ll(ptr, &__pus_tmp, sizeof(*(ptr))) != 0)) __ret_pu=-EFAULT; __ret_pu; })
+
+#define __get_user(x,ptr) __get_user_nocheck((x),(ptr),sizeof(*(ptr)))
+
+#define __put_user(x,ptr) __put_user_nocheck((__typeof__(*(ptr)))(x),(ptr),sizeof(*(ptr)))
+
+#define __put_user_nocheck(x,ptr,size) ({ long __pu_err; __put_user_size((x),(ptr),(size),__pu_err,-EFAULT); __pu_err; })
+
+#define __put_user_u64(x, addr, err) __asm__ __volatile__( "1: movl %%eax,0(%2)\n" "2: movl %%edx,4(%2)\n" "3:\n" ".section .fixup,\"ax\"\n" "4: movl %3,%0\n" " jmp 3b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,4b\n" " .long 2b,4b\n" ".previous" : "=r"(err) : "A" (x), "r" (addr), "i"(-EFAULT), "0"(err))
+
+#define __put_user_size(x,ptr,size,retval,errret) do { __typeof__(*(ptr)) __pus_tmp = x; retval = 0; if(unlikely(__copy_to_user_ll(ptr, &__pus_tmp, size) != 0)) retval = errret; } while (0)
+
+struct __large_struct { unsigned long buf[100]; };
+#define __m(x) (*(struct __large_struct __user *)(x))
+
+#define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) __asm__ __volatile__( "1: mov"itype" %"rtype"1,%2\n" "2:\n" ".section .fixup,\"ax\"\n" "3: movl %3,%0\n" " jmp 2b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,3b\n" ".previous" : "=r"(err) : ltype (x), "m"(__m(addr)), "i"(errret), "0"(err))
+
+#define __get_user_nocheck(x,ptr,size) ({ long __gu_err; unsigned long __gu_val; __get_user_size(__gu_val,(ptr),(size),__gu_err,-EFAULT); (x) = (__typeof__(*(ptr)))__gu_val; __gu_err; })
+
+#define __get_user_size(x,ptr,size,retval,errret) do { retval = 0; __chk_user_ptr(ptr); switch (size) { case 1: __get_user_asm(x,ptr,retval,"b","b","=q",errret);break; case 2: __get_user_asm(x,ptr,retval,"w","w","=r",errret);break; case 4: __get_user_asm(x,ptr,retval,"l","","=r",errret);break; default: (x) = __get_user_bad(); } } while (0)
+
+#define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) __asm__ __volatile__( "1: mov"itype" %2,%"rtype"1\n" "2:\n" ".section .fixup,\"ax\"\n" "3: movl %3,%0\n" " xor"itype" %"rtype"1,%"rtype"1\n" " jmp 2b\n" ".previous\n" ".section __ex_table,\"a\"\n" " .align 4\n" " .long 1b,3b\n" ".previous" : "=r"(err), ltype (x) : "m"(__m(addr)), "i"(errret), "0"(err))
+
+#define ARCH_HAS_NOCACHE_UACCESS
+
+#define strlen_user(str) strnlen_user(str, LONG_MAX)
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/unaligned.h b/libc/kernel/arch-x86/asm/unaligned.h
new file mode 100644
index 0000000..ce7a8a7
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/unaligned.h
@@ -0,0 +1,19 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_UNALIGNED_H
+#define _ASM_X86_UNALIGNED_H
+
+#define get_unaligned(ptr) (*(ptr))
+
+#define put_unaligned(val, ptr) ((void)( *(ptr) = (val) ))
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/unistd.h b/libc/kernel/arch-x86/asm/unistd.h
new file mode 100644
index 0000000..769f836
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/unistd.h
@@ -0,0 +1,16 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifdef __i386__
+#include "unistd_32.h"
+#else
+#include "unistd_64.h"
+#endif
diff --git a/libc/kernel/arch-x86/asm/unistd_32.h b/libc/kernel/arch-x86/asm/unistd_32.h
new file mode 100644
index 0000000..b3d8b19
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/unistd_32.h
@@ -0,0 +1,341 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_I386_UNISTD_H_
+#define _ASM_I386_UNISTD_H_
+
+#define __NR_restart_syscall 0
+#define __NR_exit 1
+#define __NR_fork 2
+#define __NR_read 3
+#define __NR_write 4
+#define __NR_open 5
+#define __NR_close 6
+#define __NR_waitpid 7
+#define __NR_creat 8
+#define __NR_link 9
+#define __NR_unlink 10
+#define __NR_execve 11
+#define __NR_chdir 12
+#define __NR_time 13
+#define __NR_mknod 14
+#define __NR_chmod 15
+#define __NR_lchown 16
+#define __NR_break 17
+#define __NR_oldstat 18
+#define __NR_lseek 19
+#define __NR_getpid 20
+#define __NR_mount 21
+#define __NR_umount 22
+#define __NR_setuid 23
+#define __NR_getuid 24
+#define __NR_stime 25
+#define __NR_ptrace 26
+#define __NR_alarm 27
+#define __NR_oldfstat 28
+#define __NR_pause 29
+#define __NR_utime 30
+#define __NR_stty 31
+#define __NR_gtty 32
+#define __NR_access 33
+#define __NR_nice 34
+#define __NR_ftime 35
+#define __NR_sync 36
+#define __NR_kill 37
+#define __NR_rename 38
+#define __NR_mkdir 39
+#define __NR_rmdir 40
+#define __NR_dup 41
+#define __NR_pipe 42
+#define __NR_times 43
+#define __NR_prof 44
+#define __NR_brk 45
+#define __NR_setgid 46
+#define __NR_getgid 47
+#define __NR_signal 48
+#define __NR_geteuid 49
+#define __NR_getegid 50
+#define __NR_acct 51
+#define __NR_umount2 52
+#define __NR_lock 53
+#define __NR_ioctl 54
+#define __NR_fcntl 55
+#define __NR_mpx 56
+#define __NR_setpgid 57
+#define __NR_ulimit 58
+#define __NR_oldolduname 59
+#define __NR_umask 60
+#define __NR_chroot 61
+#define __NR_ustat 62
+#define __NR_dup2 63
+#define __NR_getppid 64
+#define __NR_getpgrp 65
+#define __NR_setsid 66
+#define __NR_sigaction 67
+#define __NR_sgetmask 68
+#define __NR_ssetmask 69
+#define __NR_setreuid 70
+#define __NR_setregid 71
+#define __NR_sigsuspend 72
+#define __NR_sigpending 73
+#define __NR_sethostname 74
+#define __NR_setrlimit 75
+#define __NR_getrlimit 76
+#define __NR_getrusage 77
+#define __NR_gettimeofday 78
+#define __NR_settimeofday 79
+#define __NR_getgroups 80
+#define __NR_setgroups 81
+#define __NR_select 82
+#define __NR_symlink 83
+#define __NR_oldlstat 84
+#define __NR_readlink 85
+#define __NR_uselib 86
+#define __NR_swapon 87
+#define __NR_reboot 88
+#define __NR_readdir 89
+#define __NR_mmap 90
+#define __NR_munmap 91
+#define __NR_truncate 92
+#define __NR_ftruncate 93
+#define __NR_fchmod 94
+#define __NR_fchown 95
+#define __NR_getpriority 96
+#define __NR_setpriority 97
+#define __NR_profil 98
+#define __NR_statfs 99
+#define __NR_fstatfs 100
+#define __NR_ioperm 101
+#define __NR_socketcall 102
+#define __NR_syslog 103
+#define __NR_setitimer 104
+#define __NR_getitimer 105
+#define __NR_stat 106
+#define __NR_lstat 107
+#define __NR_fstat 108
+#define __NR_olduname 109
+#define __NR_iopl 110
+#define __NR_vhangup 111
+#define __NR_idle 112
+#define __NR_vm86old 113
+#define __NR_wait4 114
+#define __NR_swapoff 115
+#define __NR_sysinfo 116
+#define __NR_ipc 117
+#define __NR_fsync 118
+#define __NR_sigreturn 119
+#define __NR_clone 120
+#define __NR_setdomainname 121
+#define __NR_uname 122
+#define __NR_modify_ldt 123
+#define __NR_adjtimex 124
+#define __NR_mprotect 125
+#define __NR_sigprocmask 126
+#define __NR_create_module 127
+#define __NR_init_module 128
+#define __NR_delete_module 129
+#define __NR_get_kernel_syms 130
+#define __NR_quotactl 131
+#define __NR_getpgid 132
+#define __NR_fchdir 133
+#define __NR_bdflush 134
+#define __NR_sysfs 135
+#define __NR_personality 136
+#define __NR_afs_syscall 137
+#define __NR_setfsuid 138
+#define __NR_setfsgid 139
+#define __NR__llseek 140
+#define __NR_getdents 141
+#define __NR__newselect 142
+#define __NR_flock 143
+#define __NR_msync 144
+#define __NR_readv 145
+#define __NR_writev 146
+#define __NR_getsid 147
+#define __NR_fdatasync 148
+#define __NR__sysctl 149
+#define __NR_mlock 150
+#define __NR_munlock 151
+#define __NR_mlockall 152
+#define __NR_munlockall 153
+#define __NR_sched_setparam 154
+#define __NR_sched_getparam 155
+#define __NR_sched_setscheduler 156
+#define __NR_sched_getscheduler 157
+#define __NR_sched_yield 158
+#define __NR_sched_get_priority_max 159
+#define __NR_sched_get_priority_min 160
+#define __NR_sched_rr_get_interval 161
+#define __NR_nanosleep 162
+#define __NR_mremap 163
+#define __NR_setresuid 164
+#define __NR_getresuid 165
+#define __NR_vm86 166
+#define __NR_query_module 167
+#define __NR_poll 168
+#define __NR_nfsservctl 169
+#define __NR_setresgid 170
+#define __NR_getresgid 171
+#define __NR_prctl 172
+#define __NR_rt_sigreturn 173
+#define __NR_rt_sigaction 174
+#define __NR_rt_sigprocmask 175
+#define __NR_rt_sigpending 176
+#define __NR_rt_sigtimedwait 177
+#define __NR_rt_sigqueueinfo 178
+#define __NR_rt_sigsuspend 179
+#define __NR_pread64 180
+#define __NR_pwrite64 181
+#define __NR_chown 182
+#define __NR_getcwd 183
+#define __NR_capget 184
+#define __NR_capset 185
+#define __NR_sigaltstack 186
+#define __NR_sendfile 187
+#define __NR_getpmsg 188
+#define __NR_putpmsg 189
+#define __NR_vfork 190
+#define __NR_ugetrlimit 191
+#define __NR_mmap2 192
+#define __NR_truncate64 193
+#define __NR_ftruncate64 194
+#define __NR_stat64 195
+#define __NR_lstat64 196
+#define __NR_fstat64 197
+#define __NR_lchown32 198
+#define __NR_getuid32 199
+#define __NR_getgid32 200
+#define __NR_geteuid32 201
+#define __NR_getegid32 202
+#define __NR_setreuid32 203
+#define __NR_setregid32 204
+#define __NR_getgroups32 205
+#define __NR_setgroups32 206
+#define __NR_fchown32 207
+#define __NR_setresuid32 208
+#define __NR_getresuid32 209
+#define __NR_setresgid32 210
+#define __NR_getresgid32 211
+#define __NR_chown32 212
+#define __NR_setuid32 213
+#define __NR_setgid32 214
+#define __NR_setfsuid32 215
+#define __NR_setfsgid32 216
+#define __NR_pivot_root 217
+#define __NR_mincore 218
+#define __NR_madvise 219
+#define __NR_madvise1 219
+#define __NR_getdents64 220
+#define __NR_fcntl64 221
+
+#define __NR_gettid 224
+#define __NR_readahead 225
+#define __NR_setxattr 226
+#define __NR_lsetxattr 227
+#define __NR_fsetxattr 228
+#define __NR_getxattr 229
+#define __NR_lgetxattr 230
+#define __NR_fgetxattr 231
+#define __NR_listxattr 232
+#define __NR_llistxattr 233
+#define __NR_flistxattr 234
+#define __NR_removexattr 235
+#define __NR_lremovexattr 236
+#define __NR_fremovexattr 237
+#define __NR_tkill 238
+#define __NR_sendfile64 239
+#define __NR_futex 240
+#define __NR_sched_setaffinity 241
+#define __NR_sched_getaffinity 242
+#define __NR_set_thread_area 243
+#define __NR_get_thread_area 244
+#define __NR_io_setup 245
+#define __NR_io_destroy 246
+#define __NR_io_getevents 247
+#define __NR_io_submit 248
+#define __NR_io_cancel 249
+#define __NR_fadvise64 250
+
+#define __NR_exit_group 252
+#define __NR_lookup_dcookie 253
+#define __NR_epoll_create 254
+#define __NR_epoll_ctl 255
+#define __NR_epoll_wait 256
+#define __NR_remap_file_pages 257
+#define __NR_set_tid_address 258
+#define __NR_timer_create 259
+#define __NR_timer_settime (__NR_timer_create+1)
+#define __NR_timer_gettime (__NR_timer_create+2)
+#define __NR_timer_getoverrun (__NR_timer_create+3)
+#define __NR_timer_delete (__NR_timer_create+4)
+#define __NR_clock_settime (__NR_timer_create+5)
+#define __NR_clock_gettime (__NR_timer_create+6)
+#define __NR_clock_getres (__NR_timer_create+7)
+#define __NR_clock_nanosleep (__NR_timer_create+8)
+#define __NR_statfs64 268
+#define __NR_fstatfs64 269
+#define __NR_tgkill 270
+#define __NR_utimes 271
+#define __NR_fadvise64_64 272
+#define __NR_vserver 273
+#define __NR_mbind 274
+#define __NR_get_mempolicy 275
+#define __NR_set_mempolicy 276
+#define __NR_mq_open 277
+#define __NR_mq_unlink (__NR_mq_open+1)
+#define __NR_mq_timedsend (__NR_mq_open+2)
+#define __NR_mq_timedreceive (__NR_mq_open+3)
+#define __NR_mq_notify (__NR_mq_open+4)
+#define __NR_mq_getsetattr (__NR_mq_open+5)
+#define __NR_kexec_load 283
+#define __NR_waitid 284
+
+#define __NR_add_key 286
+#define __NR_request_key 287
+#define __NR_keyctl 288
+#define __NR_ioprio_set 289
+#define __NR_ioprio_get 290
+#define __NR_inotify_init 291
+#define __NR_inotify_add_watch 292
+#define __NR_inotify_rm_watch 293
+#define __NR_migrate_pages 294
+#define __NR_openat 295
+#define __NR_mkdirat 296
+#define __NR_mknodat 297
+#define __NR_fchownat 298
+#define __NR_futimesat 299
+#define __NR_fstatat64 300
+#define __NR_unlinkat 301
+#define __NR_renameat 302
+#define __NR_linkat 303
+#define __NR_symlinkat 304
+#define __NR_readlinkat 305
+#define __NR_fchmodat 306
+#define __NR_faccessat 307
+#define __NR_pselect6 308
+#define __NR_ppoll 309
+#define __NR_unshare 310
+#define __NR_set_robust_list 311
+#define __NR_get_robust_list 312
+#define __NR_splice 313
+#define __NR_sync_file_range 314
+#define __NR_tee 315
+#define __NR_vmsplice 316
+#define __NR_move_pages 317
+#define __NR_getcpu 318
+#define __NR_epoll_pwait 319
+#define __NR_utimensat 320
+#define __NR_signalfd 321
+#define __NR_timerfd 322
+#define __NR_eventfd 323
+#define __NR_fallocate 324
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/user.h b/libc/kernel/arch-x86/asm/user.h
new file mode 100644
index 0000000..980b0aa
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/user.h
@@ -0,0 +1,16 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifdef __i386__
+#include "user_32.h"
+#else
+#include "user_64.h"
+#endif
diff --git a/libc/kernel/arch-x86/asm/user32.h b/libc/kernel/arch-x86/asm/user32.h
new file mode 100644
index 0000000..89eabb1
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/user32.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef USER32_H
+#define USER32_H 1
+
+struct user_i387_ia32_struct {
+ u32 cwd;
+ u32 swd;
+ u32 twd;
+ u32 fip;
+ u32 fcs;
+ u32 foo;
+ u32 fos;
+ u32 st_space[20];
+};
+
+struct user32_fxsr_struct {
+ unsigned short cwd;
+ unsigned short swd;
+ unsigned short twd;
+ unsigned short fop;
+ int fip;
+ int fcs;
+ int foo;
+ int fos;
+ int mxcsr;
+ int reserved;
+ int st_space[32];
+ int xmm_space[32];
+ int padding[56];
+};
+
+struct user_regs_struct32 {
+ __u32 ebx, ecx, edx, esi, edi, ebp, eax;
+ unsigned short ds, __ds, es, __es;
+ unsigned short fs, __fs, gs, __gs;
+ __u32 orig_eax, eip;
+ unsigned short cs, __cs;
+ __u32 eflags, esp;
+ unsigned short ss, __ss;
+};
+
+struct user32 {
+ struct user_regs_struct32 regs;
+ int u_fpvalid;
+
+ struct user_i387_ia32_struct i387;
+
+ __u32 u_tsize;
+ __u32 u_dsize;
+ __u32 u_ssize;
+ __u32 start_code;
+ __u32 start_stack;
+ __u32 signal;
+ int reserved;
+ __u32 u_ar0;
+
+ __u32 u_fpstate;
+ __u32 magic;
+ char u_comm[32];
+ int u_debugreg[8];
+};
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/user_32.h b/libc/kernel/arch-x86/asm/user_32.h
new file mode 100644
index 0000000..8e0296c
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/user_32.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _I386_USER_H
+#define _I386_USER_H
+
+#include <asm/page.h>
+
+struct user_i387_struct {
+ long cwd;
+ long swd;
+ long twd;
+ long fip;
+ long fcs;
+ long foo;
+ long fos;
+ long st_space[20];
+};
+
+struct user_fxsr_struct {
+ unsigned short cwd;
+ unsigned short swd;
+ unsigned short twd;
+ unsigned short fop;
+ long fip;
+ long fcs;
+ long foo;
+ long fos;
+ long mxcsr;
+ long reserved;
+ long st_space[32];
+ long xmm_space[32];
+ long padding[56];
+};
+
+struct user_regs_struct {
+ long ebx, ecx, edx, esi, edi, ebp, eax;
+ unsigned short ds, __ds, es, __es;
+ unsigned short fs, __fs, gs, __gs;
+ long orig_eax, eip;
+ unsigned short cs, __cs;
+ long eflags, esp;
+ unsigned short ss, __ss;
+};
+
+struct user{
+
+ struct user_regs_struct regs;
+
+ int u_fpvalid;
+
+ struct user_i387_struct i387;
+
+ unsigned long int u_tsize;
+ unsigned long int u_dsize;
+ unsigned long int u_ssize;
+ unsigned long start_code;
+ unsigned long start_stack;
+ long int signal;
+ int reserved;
+ struct user_pt_regs * u_ar0;
+
+ struct user_i387_struct* u_fpstate;
+ unsigned long magic;
+ char u_comm[32];
+ int u_debugreg[8];
+};
+#define NBPG PAGE_SIZE
+#define UPAGES 1
+#define HOST_TEXT_START_ADDR (u.start_code)
+#define HOST_STACK_END_ADDR (u.start_stack + u.u_ssize * NBPG)
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/vm86.h b/libc/kernel/arch-x86/asm/vm86.h
new file mode 100644
index 0000000..d0e71f1
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/vm86.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _LINUX_VM86_H
+#define _LINUX_VM86_H
+
+#define TF_MASK 0x00000100
+#define IF_MASK 0x00000200
+#define IOPL_MASK 0x00003000
+#define NT_MASK 0x00004000
+#define VM_MASK 0
+#define AC_MASK 0x00040000
+#define VIF_MASK 0x00080000
+#define VIP_MASK 0x00100000
+#define ID_MASK 0x00200000
+
+#define BIOSSEG 0x0f000
+
+#define CPU_086 0
+#define CPU_186 1
+#define CPU_286 2
+#define CPU_386 3
+#define CPU_486 4
+#define CPU_586 5
+
+#define VM86_TYPE(retval) ((retval) & 0xff)
+#define VM86_ARG(retval) ((retval) >> 8)
+
+#define VM86_SIGNAL 0
+#define VM86_UNKNOWN 1
+#define VM86_INTx 2
+#define VM86_STI 3
+
+#define VM86_PICRETURN 4
+#define VM86_TRAP 6
+
+#define VM86_PLUS_INSTALL_CHECK 0
+#define VM86_ENTER 1
+#define VM86_ENTER_NO_BYPASS 2
+#define VM86_REQUEST_IRQ 3
+#define VM86_FREE_IRQ 4
+#define VM86_GET_IRQ_BITS 5
+#define VM86_GET_AND_RESET_IRQ 6
+
+struct vm86_regs {
+
+ long ebx;
+ long ecx;
+ long edx;
+ long esi;
+ long edi;
+ long ebp;
+ long eax;
+ long __null_ds;
+ long __null_es;
+ long __null_fs;
+ long __null_gs;
+ long orig_eax;
+ long eip;
+ unsigned short cs, __csh;
+ long eflags;
+ long esp;
+ unsigned short ss, __ssh;
+
+ unsigned short es, __esh;
+ unsigned short ds, __dsh;
+ unsigned short fs, __fsh;
+ unsigned short gs, __gsh;
+};
+
+struct revectored_struct {
+ unsigned long __map[8];
+};
+
+struct vm86_struct {
+ struct vm86_regs regs;
+ unsigned long flags;
+ unsigned long screen_bitmap;
+ unsigned long cpu_type;
+ struct revectored_struct int_revectored;
+ struct revectored_struct int21_revectored;
+};
+
+#define VM86_SCREEN_BITMAP 0x0001
+
+struct vm86plus_info_struct {
+ unsigned long force_return_for_pic:1;
+ unsigned long vm86dbg_active:1;
+ unsigned long vm86dbg_TFpendig:1;
+ unsigned long unused:28;
+ unsigned long is_vm86pus:1;
+ unsigned char vm86dbg_intxxtab[32];
+};
+
+struct vm86plus_struct {
+ struct vm86_regs regs;
+ unsigned long flags;
+ unsigned long screen_bitmap;
+ unsigned long cpu_type;
+ struct revectored_struct int_revectored;
+ struct revectored_struct int21_revectored;
+ struct vm86plus_info_struct vm86plus;
+};
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/voyager.h b/libc/kernel/arch-x86/asm/voyager.h
new file mode 100644
index 0000000..c6f50a9
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/voyager.h
@@ -0,0 +1,437 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#undef VOYAGER_DEBUG
+#undef VOYAGER_CAT_DEBUG
+
+#ifdef VOYAGER_DEBUG
+#define VDEBUG(x) printk x
+#else
+#define VDEBUG(x)
+#endif
+
+#define VOYAGER_LEVEL5_AND_ABOVE 0x3435
+#define VOYAGER_LEVEL4 0x3360
+
+#define VOYAGER_DINO 0x43
+
+#define VOYAGER_MC_SETUP 0x96
+
+#define VOYAGER_CAT_CONFIG_PORT 0x97
+#define VOYAGER_CAT_DESELECT 0xff
+#define VOYAGER_SSPB_RELOCATION_PORT 0x98
+
+#define VOYAGER_CAT_IRCYC 0x01
+
+#define VOYAGER_CAT_DRCYC 0x02
+
+#define VOYAGER_CAT_RUN 0x0F
+
+#define VOYAGER_CAT_END 0x80
+
+#define VOYAGER_CAT_HOLD 0x90
+
+#define VOYAGER_CAT_STEP 0xE0
+
+#define VOYAGER_CAT_CLEMSON 0xFF
+
+#define VOYAGER_CAT_HEADER 0x7F
+
+#define VOYAGER_MIN_MODULE 0x10
+#define VOYAGER_MAX_MODULE 0x1f
+
+#define VOYAGER_ASIC_ID_REG 0x00
+#define VOYAGER_ASIC_TYPE_REG 0x01
+
+#define VOYAGER_AUTO_INC_REG 0x02
+#define VOYAGER_AUTO_INC 0x04
+#define VOYAGER_NO_AUTO_INC 0xfb
+#define VOYAGER_SUBADDRDATA 0x03
+#define VOYAGER_SCANPATH 0x05
+#define VOYAGER_CONNECT_ASIC 0x01
+#define VOYAGER_DISCONNECT_ASIC 0xfe
+#define VOYAGER_SUBADDRLO 0x06
+#define VOYAGER_SUBADDRHI 0x07
+#define VOYAGER_SUBMODSELECT 0x08
+#define VOYAGER_SUBMODPRESENT 0x09
+
+#define VOYAGER_SUBADDR_LO 0xff
+#define VOYAGER_SUBADDR_HI 0xffff
+
+#define VOYAGER_MAX_SCAN_PATH 0x100
+
+#define VOYAGER_MAX_REG_SIZE 4
+
+#define VOYAGER_MAX_MODULES 16
+
+#define VOYAGER_MAX_ASICS_PER_MODULE 7
+
+#define VOYAGER_CAT_ID 0
+#define VOYAGER_PSI 0x1a
+
+#define VOYAGER_READ_CONFIG 0x1
+#define VOYAGER_WRITE_CONFIG 0x2
+#define VOYAGER_BYPASS 0xff
+
+typedef struct voyager_asic
+{
+ __u8 asic_addr;
+ __u8 asic_type;
+ __u8 asic_id;
+ __u8 jtag_id[4];
+ __u8 asic_location;
+ __u8 bit_location;
+ __u8 ireg_length;
+ __u16 subaddr;
+ struct voyager_asic *next;
+} voyager_asic_t;
+
+typedef struct voyager_module {
+ __u8 module_addr;
+ __u8 scan_path_connected;
+ __u16 ee_size;
+ __u16 num_asics;
+ __u16 inst_bits;
+ __u16 largest_reg;
+ __u16 smallest_reg;
+ voyager_asic_t *asic;
+ struct voyager_module *submodule;
+ struct voyager_module *next;
+} voyager_module_t;
+
+typedef struct voyager_eeprom_hdr {
+ __u8 module_id[4];
+ __u8 version_id;
+ __u8 config_id;
+ __u16 boundry_id;
+ __u16 ee_size;
+ __u8 assembly[11];
+ __u8 assembly_rev;
+ __u8 tracer[4];
+ __u16 assembly_cksum;
+ __u16 power_consump;
+ __u16 num_asics;
+ __u16 bist_time;
+ __u16 err_log_offset;
+ __u16 scan_path_offset;
+ __u16 cct_offset;
+ __u16 log_length;
+ __u16 xsum_end;
+ __u8 reserved[4];
+ __u8 sflag;
+ __u8 part_number[13];
+ __u8 version[10];
+ __u8 signature[8];
+ __u16 eeprom_chksum;
+ __u32 data_stamp_offset;
+ __u8 eflag ;
+} __attribute__((packed)) voyager_eprom_hdr_t;
+
+#define VOYAGER_EPROM_SIZE_OFFSET ((__u16)(&(((voyager_eprom_hdr_t *)0)->ee_size)))
+#define VOYAGER_XSUM_END_OFFSET 0x2a
+
+typedef struct voyager_sp_table {
+ __u8 asic_id;
+ __u8 bypass_flag;
+ __u16 asic_data_offset;
+ __u16 config_data_offset;
+} __attribute__((packed)) voyager_sp_table_t;
+
+typedef struct voyager_jtag_table {
+ __u8 icode[4];
+ __u8 runbist[4];
+ __u8 intest[4];
+ __u8 samp_preld[4];
+ __u8 ireg_len;
+} __attribute__((packed)) voyager_jtt_t;
+
+typedef struct voyager_asic_data_table {
+ __u8 jtag_id[4];
+ __u16 length_bsr;
+ __u16 length_bist_reg;
+ __u32 bist_clk;
+ __u16 subaddr_bits;
+ __u16 seed_bits;
+ __u16 sig_bits;
+ __u16 jtag_offset;
+} __attribute__((packed)) voyager_at_t;
+
+#define VOYAGER_WCBIC0 0x41
+#define VOYAGER_WCBIC1 0x49
+#define VOYAGER_WCBIC2 0x51
+#define VOYAGER_WCBIC3 0x59
+#define VOYAGER_WCBIC4 0x61
+#define VOYAGER_WCBIC5 0x69
+#define VOYAGER_WCBIC6 0x71
+#define VOYAGER_WCBIC7 0x79
+
+#define VOYAGER_WCBIC_TOM_L 0x4
+#define VOYAGER_WCBIC_TOM_H 0x5
+
+#define VOYAGER_VMC1 0x81
+#define VOYAGER_VMC2 0x91
+#define VOYAGER_VMC3 0xa1
+#define VOYAGER_VMC4 0xb1
+
+#define VOYAGER_VMC_MEMORY_SETUP 0x9
+#define VMC_Interleaving 0x01
+#define VMC_4Way 0x02
+#define VMC_EvenCacheLines 0x04
+#define VMC_HighLine 0x08
+#define VMC_Start0_Enable 0x20
+#define VMC_Start1_Enable 0x40
+#define VMC_Vremap 0x80
+#define VOYAGER_VMC_BANK_DENSITY 0xa
+#define VMC_BANK_EMPTY 0
+#define VMC_BANK_4MB 1
+#define VMC_BANK_16MB 2
+#define VMC_BANK_64MB 3
+#define VMC_BANK0_MASK 0x03
+#define VMC_BANK1_MASK 0x0C
+#define VMC_BANK2_MASK 0x30
+#define VMC_BANK3_MASK 0xC0
+
+#define VOYAGER_MMC_ASIC_ID 1
+
+#define VOYAGER_MMC_MEMORY0_MODULE 0x14
+#define VOYAGER_MMC_MEMORY1_MODULE 0x15
+
+#define VOYAGER_MMA_ASIC_ID 2
+
+#define VOYAGER_QUAD_BASEBOARD 1
+
+#define VOYAGER_QUAD_QDATA0 1
+#define VOYAGER_QUAD_QDATA1 2
+#define VOYAGER_QUAD_QABC 3
+
+#define VOYAGER_PROCESSOR_PRESENT_MASK 0x88a
+#define VOYAGER_MEMORY_CLICKMAP 0xa23
+#define VOYAGER_DUMP_LOCATION 0xb1a
+
+#define VOYAGER_SUS_IN_CONTROL_PORT 0x3ff
+#define VOYAGER_IN_CONTROL_FLAG 0x80
+
+#define VOYAGER_PSI_STATUS_REG 0x08
+#define PSI_DC_FAIL 0x01
+#define PSI_MON 0x02
+#define PSI_FAULT 0x04
+#define PSI_ALARM 0x08
+#define PSI_CURRENT 0x10
+#define PSI_DVM 0x20
+#define PSI_PSCFAULT 0x40
+#define PSI_STAT_CHG 0x80
+
+#define VOYAGER_PSI_SUPPLY_REG 0x8000
+
+#define PSI_FAIL_DC 0x01
+#define PSI_FAIL_AC 0x02
+#define PSI_MON_INT 0x04
+#define PSI_SWITCH_OFF 0x08
+#define PSI_HX_OFF 0x10
+#define PSI_SECURITY 0x20
+#define PSI_CMOS_BATT_LOW 0x40
+#define PSI_CMOS_BATT_FAIL 0x80
+
+#define PSI_CLR_SWITCH_OFF 0x13
+#define PSI_CLR_HX_OFF 0x14
+#define PSI_CLR_CMOS_BATT_FAIL 0x17
+
+#define VOYAGER_PSI_MASK 0x8001
+#define PSI_MASK_MASK 0x10
+
+#define VOYAGER_PSI_AC_FAIL_REG 0x8004
+#define AC_FAIL_STAT_CHANGE 0x80
+
+#define VOYAGER_PSI_GENERAL_REG 0x8007
+
+#define PSI_SWITCH_ON 0x01
+#define PSI_SWITCH_ENABLED 0x02
+#define PSI_ALARM_ENABLED 0x08
+#define PSI_SECURE_ENABLED 0x10
+#define PSI_COLD_RESET 0x20
+#define PSI_COLD_START 0x80
+
+#define PSI_POWER_DOWN 0x10
+#define PSI_SWITCH_DISABLE 0x01
+#define PSI_SWITCH_ENABLE 0x11
+#define PSI_CLEAR 0x12
+#define PSI_ALARM_DISABLE 0x03
+#define PSI_ALARM_ENABLE 0x13
+#define PSI_CLEAR_COLD_RESET 0x05
+#define PSI_SET_COLD_RESET 0x15
+#define PSI_CLEAR_COLD_START 0x07
+#define PSI_SET_COLD_START 0x17
+
+struct voyager_bios_info {
+ __u8 len;
+ __u8 major;
+ __u8 minor;
+ __u8 debug;
+ __u8 num_classes;
+ __u8 class_1;
+ __u8 class_2;
+};
+
+#define NUMBER_OF_MC_BUSSES 2
+#define SLOTS_PER_MC_BUS 8
+#define MAX_CPUS 16
+#define MAX_PROCESSOR_BOARDS 4
+#define MAX_CACHE_LEVELS 4
+#define MAX_SHARED_CPUS 4
+#define NUMBER_OF_POS_REGS 8
+
+typedef struct {
+ __u8 MC_Slot;
+ __u8 POS_Values[NUMBER_OF_POS_REGS];
+} __attribute__((packed)) MC_SlotInformation_t;
+
+struct QuadDescription {
+ __u8 Type;
+ __u8 StructureVersion;
+ __u32 CPI_BaseAddress;
+ __u32 LARC_BankSize;
+ __u32 LocalMemoryStateBits;
+ __u8 Slot;
+} __attribute__((packed));
+
+struct ProcBoardInfo {
+ __u8 Type;
+ __u8 StructureVersion;
+ __u8 NumberOfBoards;
+ struct QuadDescription QuadData[MAX_PROCESSOR_BOARDS];
+} __attribute__((packed));
+
+struct CacheDescription {
+ __u8 Level;
+ __u32 TotalSize;
+ __u16 LineSize;
+ __u8 Associativity;
+ __u8 CacheType;
+ __u8 WriteType;
+ __u8 Number_CPUs_SharedBy;
+ __u8 Shared_CPUs_Hardware_IDs[MAX_SHARED_CPUS];
+
+} __attribute__((packed));
+
+struct CPU_Description {
+ __u8 CPU_HardwareId;
+ char *FRU_String;
+ __u8 NumberOfCacheLevels;
+ struct CacheDescription CacheLevelData[MAX_CACHE_LEVELS];
+} __attribute__((packed));
+
+struct CPU_Info {
+ __u8 Type;
+ __u8 StructureVersion;
+ __u8 NumberOf_CPUs;
+ struct CPU_Description CPU_Data[MAX_CPUS];
+} __attribute__((packed));
+
+typedef struct {
+ __u8 Mailbox_SUS;
+ __u8 Mailbox_OS;
+ __u8 SUS_MailboxVersion;
+ __u8 OS_MailboxVersion;
+ __u32 OS_Flags;
+ __u32 SUS_Flags;
+ __u32 WatchDogPeriod;
+ __u32 WatchDogCount;
+ __u32 MemoryFor_SUS_ErrorLog;
+ MC_SlotInformation_t MC_SlotInfo[NUMBER_OF_MC_BUSSES*SLOTS_PER_MC_BUS];
+
+ struct ProcBoardInfo *BoardData;
+ struct CPU_Info *CPU_Data;
+
+} Voyager_KernelSUS_Mbox_t;
+
+struct voyager_qic_cpi {
+
+ struct {
+ __u32 pad1[3];
+ __u32 cpi;
+ __u32 pad2[4];
+ } qic_cpi[8];
+};
+
+struct voyager_status {
+ __u32 power_fail:1;
+ __u32 switch_off:1;
+ __u32 request_from_kernel:1;
+};
+
+struct voyager_psi_regs {
+ __u8 cat_id;
+ __u8 cat_dev;
+ __u8 cat_control;
+ __u8 subaddr;
+ __u8 dummy4;
+ __u8 checkbit;
+ __u8 subaddr_low;
+ __u8 subaddr_high;
+ __u8 intstatus;
+ __u8 stat1;
+ __u8 stat3;
+ __u8 fault;
+ __u8 tms;
+ __u8 gen;
+ __u8 sysconf;
+ __u8 dummy15;
+};
+
+struct voyager_psi_subregs {
+ __u8 supply;
+ __u8 mask;
+ __u8 present;
+ __u8 DCfail;
+ __u8 ACfail;
+ __u8 fail;
+ __u8 UPSfail;
+ __u8 genstatus;
+};
+
+struct voyager_psi {
+ struct voyager_psi_regs regs;
+ struct voyager_psi_subregs subregs;
+};
+
+struct voyager_SUS {
+#define VOYAGER_DUMP_BUTTON_NMI 0x1
+#define VOYAGER_SUS_VALID 0x2
+#define VOYAGER_SYSINT_COMPLETE 0x3
+ __u8 SUS_mbox;
+#define VOYAGER_NO_COMMAND 0x0
+#define VOYAGER_IGNORE_DUMP 0x1
+#define VOYAGER_DO_DUMP 0x2
+#define VOYAGER_SYSINT_HANDSHAKE 0x3
+#define VOYAGER_DO_MEM_DUMP 0x4
+#define VOYAGER_SYSINT_WAS_RECOVERED 0x5
+ __u8 kernel_mbox;
+#define VOYAGER_MAILBOX_VERSION 0x10
+ __u8 SUS_version;
+ __u8 kernel_version;
+#define VOYAGER_OS_HAS_SYSINT 0x1
+#define VOYAGER_OS_IN_PROGRESS 0x2
+#define VOYAGER_UPDATING_WDPERIOD 0x4
+ __u32 kernel_flags;
+#define VOYAGER_SUS_BOOTING 0x1
+#define VOYAGER_SUS_IN_PROGRESS 0x2
+ __u32 SUS_flags;
+ __u32 watchdog_period;
+ __u32 watchdog_count;
+ __u32 SUS_errorlog;
+
+};
+
+#define VOYAGER_PSI_READ 0
+#define VOYAGER_PSI_WRITE 1
+#define VOYAGER_PSI_SUBREAD 2
+#define VOYAGER_PSI_SUBWRITE 3
+
diff --git a/libc/kernel/arch-x86/asm/vsyscall.h b/libc/kernel/arch-x86/asm/vsyscall.h
new file mode 100644
index 0000000..a7bee3b
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/vsyscall.h
@@ -0,0 +1,27 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef _ASM_X86_64_VSYSCALL_H_
+#define _ASM_X86_64_VSYSCALL_H_
+
+enum vsyscall_num {
+ __NR_vgettimeofday,
+ __NR_vtime,
+ __NR_vgetcpu,
+};
+
+#define VSYSCALL_START (-10UL << 20)
+#define VSYSCALL_SIZE 1024
+#define VSYSCALL_END (-2UL << 20)
+#define VSYSCALL_MAPPED_PAGES 1
+#define VSYSCALL_ADDR(vsyscall_nr) (VSYSCALL_START+VSYSCALL_SIZE*(vsyscall_nr))
+
+#endif
diff --git a/libc/kernel/arch-x86/asm/xen/hypercall.h b/libc/kernel/arch-x86/asm/xen/hypercall.h
new file mode 100644
index 0000000..3c523a8
--- /dev/null
+++ b/libc/kernel/arch-x86/asm/xen/hypercall.h
@@ -0,0 +1,34 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __HYPERCALL_H__
+#define __HYPERCALL_H__
+
+#include <linux/errno.h>
+#include <linux/string.h>
+
+#include <xen/interface/xen.h>
+#include <xen/interface/sched.h>
+#include <xen/interface/physdev.h>
+
+#define _hypercall0(type, name) ({ long __res; asm volatile ( "call %[call]" : "=a" (__res) : [call] "m" (hypercall_page[__HYPERVISOR_##name]) : "memory" ); (type)__res; })
+
+#define _hypercall1(type, name, a1) ({ long __res, __ign1; asm volatile ( "call %[call]" : "=a" (__res), "=b" (__ign1) : "1" ((long)(a1)), [call] "m" (hypercall_page[__HYPERVISOR_##name]) : "memory" ); (type)__res; })
+
+#define _hypercall2(type, name, a1, a2) ({ long __res, __ign1, __ign2; asm volatile ( "call %[call]" : "=a" (__res), "=b" (__ign1), "=c" (__ign2) : "1" ((long)(a1)), "2" ((long)(a2)), [call] "m" (hypercall_page[__HYPERVISOR_##name]) : "memory" ); (type)__res; })
+
+#define _hypercall3(type, name, a1, a2, a3) ({ long __res, __ign1, __ign2, __ign3; asm volatile ( "call %[call]" : "=a" (__res), "=b" (__ign1), "=c" (__ign2), "=d" (__ign3) : "1" ((long)(a1)), "2" ((long)(a2)), "3" ((long)(a3)), [call] "m" (hypercall_page[__HYPERVISOR_##name]) : "memory" ); (type)__res; })
+
+#define _hypercall4(type, name, a1, a2, a3, a4) ({ long __res, __ign1, __ign2, __ign3, __ign4; asm volatile ( "call %[call]" : "=a" (__res), "=b" (__ign1), "=c" (__ign2), "=d" (__ign3), "=S" (__ign4) : "1" ((long)(a1)), "2" ((long)(a2)), "3" ((long)(a3)), "4" ((long)(a4)), [call] "m" (hypercall_page[__HYPERVISOR_##name]) : "memory" ); (type)__res; })
+
+#define _hypercall5(type, name, a1, a2, a3, a4, a5) ({ long __res, __ign1, __ign2, __ign3, __ign4, __ign5; asm volatile ( "call %[call]" : "=a" (__res), "=b" (__ign1), "=c" (__ign2), "=d" (__ign3), "=S" (__ign4), "=D" (__ign5) : "1" ((long)(a1)), "2" ((long)(a2)), "3" ((long)(a3)), "4" ((long)(a4)), "5" ((long)(a5)), [call] "m" (hypercall_page[__HYPERVISOR_##name]) : "memory" ); (type)__res; })
+
+#endif
diff --git a/libc/kernel/common/asm-generic/poll.h b/libc/kernel/common/asm-generic/poll.h
new file mode 100644
index 0000000..b8cd3da
--- /dev/null
+++ b/libc/kernel/common/asm-generic/poll.h
@@ -0,0 +1,46 @@
+/****************************************************************************
+ ****************************************************************************
+ ***
+ *** 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.
+ ***
+ ****************************************************************************
+ ****************************************************************************/
+#ifndef __ASM_GENERIC_POLL_H
+#define __ASM_GENERIC_POLL_H
+
+#define POLLIN 0x0001
+#define POLLPRI 0x0002
+#define POLLOUT 0x0004
+#define POLLERR 0x0008
+#define POLLHUP 0x0010
+#define POLLNVAL 0x0020
+
+#define POLLRDNORM 0x0040
+#define POLLRDBAND 0x0080
+#ifndef POLLWRNORM
+#define POLLWRNORM 0x0100
+#endif
+#ifndef POLLWRBAND
+#define POLLWRBAND 0x0200
+#endif
+#ifndef POLLMSG
+#define POLLMSG 0x0400
+#endif
+#ifndef POLLREMOVE
+#define POLLREMOVE 0x1000
+#endif
+#ifndef POLLRDHUP
+#define POLLRDHUP 0x2000
+#endif
+
+struct pollfd {
+ int fd;
+ short events;
+ short revents;
+};
+
+#endif
diff --git a/libc/kernel/common/linux/android_alarm.h b/libc/kernel/common/linux/android_alarm.h
index 8a95615..80828ea 100644
--- a/libc/kernel/common/linux/android_alarm.h
+++ b/libc/kernel/common/linux/android_alarm.h
@@ -42,6 +42,7 @@ typedef enum {
#define ANDROID_ALARM_SET_AND_WAIT(type) _IOW('a', 3 | ((type) << 4), struct timespec)
#define ANDROID_ALARM_GET_TIME(type) _IOW('a', 4 | ((type) << 4), struct timespec)
#define ANDROID_ALARM_SET_RTC _IOW('a', 5, struct timespec)
+#define ANDROID_ALARM_SET_TIMEZONE _IOW('a', 6, struct timezone)
#define ANDROID_ALARM_BASE_CMD(cmd) (cmd & ~(_IOC(0, 0, 0xf0, 0)))
#define ANDROID_ALARM_IOCTL_TO_TYPE(cmd) (_IOC_NR(cmd) >> 4)
diff --git a/libc/kernel/common/linux/msm_mdp.h b/libc/kernel/common/linux/msm_mdp.h
index 84256aa..d10ed43 100644
--- a/libc/kernel/common/linux/msm_mdp.h
+++ b/libc/kernel/common/linux/msm_mdp.h
@@ -29,6 +29,7 @@ enum {
MDP_Y_CRCB_H2V1,
MDP_Y_CBCR_H2V1,
MDP_RGBA_8888,
+ MDP_BGRA_8888,
MDP_IMGTYPE_LIMIT
};
diff --git a/libc/kernel/tools/cpp.py b/libc/kernel/tools/cpp.py
index 33f1a06..54ebaf4 100644
--- a/libc/kernel/tools/cpp.py
+++ b/libc/kernel/tools/cpp.py
@@ -1799,7 +1799,7 @@ class BlockList:
bad = 0
if tok.id in [tokLN, tokSPACE]:
pass
- elif tok.value in [ 'struct', 'typedef', 'enum', 'union' ]:
+ elif tok.value in [ 'struct', 'typedef', 'enum', 'union', '__extension__' ]:
state = 1
else:
if tok.value in [ 'static', 'extern', '__KINLINE' ]:
diff --git a/libc/kernel/tools/defaults.py b/libc/kernel/tools/defaults.py
index 592d8b4..da78b87 100644
--- a/libc/kernel/tools/defaults.py
+++ b/libc/kernel/tools/defaults.py
@@ -36,6 +36,13 @@ kernel_known_macros = {
# but just generates cleaner results
kernel_remove_config_macros = True
+# maps an architecture to a set of default macros that would be provided by
+# toolchain preprocessor
+kernel_default_arch_macros = {
+ "arm": {},
+ "x86": {"__i386__": "1"},
+ }
+
# this is the set of known static inline functions that we want to keep
# in the final ARM headers. this is only used to keep optimized byteswapping
# static functions and stuff like that.
diff --git a/libc/kernel/tools/kernel.py b/libc/kernel/tools/kernel.py
index dba9154..9d9b5f0 100644
--- a/libc/kernel/tools/kernel.py
+++ b/libc/kernel/tools/kernel.py
@@ -57,6 +57,9 @@ class HeaderScanner:
#
re_combined =\
re.compile(r"^.*<((%s)/[\d\w_\+\.\-/]*)>.*$" % string.join(kernel_dirs,"|") )
+ # some kernel files choose to include files with relative paths (x86 32/64
+ # dispatch for instance)
+ re_rel_dir = re.compile(r'^.*"([\d\w_\+\.\-/]+)".*$')
def __init__(self,config={}):
"""initialize a HeaderScanner"""
@@ -68,13 +71,26 @@ class HeaderScanner:
self.headers = {} # maps headers to set of users
self.config = config
- def checkInclude(self,line,from_file):
+ def checkInclude(self, line, from_file, kernel_root=None):
+ relative = False
m = HeaderScanner.re_combined.match(line)
+ if kernel_root and not m:
+ m = HeaderScanner.re_rel_dir.match(line)
+ relative = True
if not m: return
header = m.group(1)
if from_file:
self.files.add(from_file)
+ if kernel_root and relative:
+ hdr_dir = os.path.realpath(os.path.dirname(from_file))
+ hdr_dir = hdr_dir.replace("%s/" % os.path.realpath(kernel_root),
+ "")
+ if hdr_dir:
+ _prefix = "%s/" % hdr_dir
+ else:
+ _prefix = ""
+ header = "%s%s" % (_prefix, header)
if not header in self.headers:
self.headers[header] = set()
@@ -84,7 +100,7 @@ class HeaderScanner:
print "=== %s uses %s" % (from_file, header)
self.headers[header].add(from_file)
- def parseFile(self,path):
+ def parseFile(self, path, arch=None, kernel_root=None):
"""parse a given file for Linux headers"""
if not os.path.exists(path):
return
@@ -100,7 +116,8 @@ class HeaderScanner:
hasIncludes = False
for line in f:
- if HeaderScanner.re_combined.match(line):
+ if (HeaderScanner.re_combined.match(line) or
+ (kernel_root and HeaderScanner.re_rel_dir.match(line))):
hasIncludes = True
break
@@ -113,11 +130,16 @@ class HeaderScanner:
list = cpp.BlockParser().parseFile(path)
if list:
#list.removePrefixed("CONFIG_",self.config)
- list.optimizeMacros(kernel_known_macros)
+ macros = kernel_known_macros.copy()
+ if kernel_root:
+ macros.update(self.config)
+ if arch and arch in kernel_default_arch_macros:
+ macros.update(kernel_default_arch_macros[arch])
+ list.optimizeMacros(macros)
list.optimizeIf01()
includes = list.findIncludes()
for inc in includes:
- self.checkInclude(inc,path)
+ self.checkInclude(inc, path, kernel_root)
def getHeaders(self):
"""return the set of all needed kernel headers"""
@@ -187,14 +209,15 @@ class KernelHeaderFinder:
self.kernel_root = kernel_root
self.kernel_config = kernel_config
self.needed = {}
+ self.setArch(arch=None)
def setArch(self,arch=None):
+ self.curr_arch = arch
+ self.arch_headers = set()
if arch:
self.prefix = "asm-%s/" % arch
- self.arch_headers = set()
else:
self.prefix = None
- self.arch_headers = set()
def pathFromHeader(self,header):
path = header
@@ -224,7 +247,8 @@ class KernelHeaderFinder:
while i < len(workqueue):
path = workqueue[i]
i += 1
- fparser.parseFile(self.kernel_root + path)
+ fparser.parseFile(self.kernel_root + path,
+ arch=self.curr_arch, kernel_root=self.kernel_root)
for used in fparser.getHeaders():
path = self.pathFromHeader(used)
if not path in needed:
diff --git a/libc/netbsd/net/getnameinfo.c b/libc/netbsd/net/getnameinfo.c
index 5effa63..db04fbf 100644
--- a/libc/netbsd/net/getnameinfo.c
+++ b/libc/netbsd/net/getnameinfo.c
@@ -335,9 +335,9 @@ ip6_parsenumeric(sa, addr, host, hostlen, flags)
size_t numaddrlen;
char numaddr[512];
- _DIAGASSERT(sa != NULL);
- _DIAGASSERT(addr != NULL);
- _DIAGASSERT(host != NULL);
+ assert(sa != NULL);
+ assert(addr != NULL);
+ assert(host != NULL);
if (inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr)) == NULL)
return EAI_SYSTEM;
@@ -380,8 +380,8 @@ ip6_sa2str(sa6, buf, bufsiz, flags)
const struct in6_addr *a6;
int n;
- _DIAGASSERT(sa6 != NULL);
- _DIAGASSERT(buf != NULL);
+ assert(sa6 != NULL);
+ assert(buf != NULL);
ifindex = (unsigned int)sa6->sin6_scope_id;
a6 = &sa6->sin6_addr;
diff --git a/libc/stdio/fclose.c b/libc/stdio/fclose.c
index bdf6e52..e94292b 100644
--- a/libc/stdio/fclose.c
+++ b/libc/stdio/fclose.c
@@ -36,6 +36,9 @@
#include <stdlib.h>
#include "local.h"
+/* BIONIC: remove any file lock associated with a FILE* pointer */
+extern void __fremovelock(FILE *fp);
+
int
fclose(FILE *fp)
{
@@ -57,5 +60,6 @@ fclose(FILE *fp)
FREELB(fp);
fp->_flags = 0; /* Release this FILE for reuse. */
fp->_r = fp->_w = 0; /* Mess up if reaccessed. */
+ __fremovelock(fp);
return (r);
}
diff --git a/libc/stdio/flockfile.c b/libc/stdio/flockfile.c
new file mode 100644
index 0000000..a81879e
--- /dev/null
+++ b/libc/stdio/flockfile.c
@@ -0,0 +1,212 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * 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.
+ *
+ * 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
+ * COPYRIGHT OWNER 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.
+ */
+
+/* implement flockfile(), ftrylockfile() and funlockfile()
+ *
+ * we can't use the OpenBSD implementation which uses kernel-specific
+ * APIs not available on Linux.
+ *
+ * Ideally, this would be trivially implemented by adding a
+ * pthread_mutex_t field to struct __sFILE as defined in
+ * <stdio.h>.
+ *
+ * However, since we don't want to bring pthread into the mix
+ * as well as change the size of a public API/ABI structure,
+ * we're going to store the data out-of-band.
+ *
+ * we use a hash-table to map FILE* pointers to recursive mutexes
+ * fclose() will call __fremovelock() defined below to remove
+ * a pointer from the table.
+ *
+ * the behaviour, if fclose() is called while the corresponding
+ * file is locked is totally undefined.
+ */
+#include <stdio.h>
+#include <pthread.h>
+#include <string.h>
+
+/* a node in the hash table */
+typedef struct FileLock {
+ struct FileLock* next;
+ FILE* file;
+ pthread_mutex_t mutex;
+} FileLock;
+
+/* use a static hash table. We assume that we're not going to
+ * lock a really large number of FILE* objects on an embedded
+ * system.
+ */
+#define FILE_LOCK_BUCKETS 32
+
+typedef struct {
+ pthread_mutex_t lock;
+ FileLock* buckets[ FILE_LOCK_BUCKETS ];
+} LockTable;
+
+static LockTable* _lockTable;
+static pthread_once_t _lockTable_once = PTHREAD_ONCE_INIT;
+
+static void
+lock_table_init( void )
+{
+ _lockTable = malloc(sizeof(*_lockTable));
+ if (_lockTable != NULL) {
+ pthread_mutex_init(&_lockTable->lock, NULL);
+ memset(_lockTable->buckets, 0, sizeof(_lockTable->buckets));
+ }
+}
+
+static LockTable*
+lock_table_lock( void )
+{
+ pthread_once( &_lockTable_once, lock_table_init );
+ pthread_mutex_lock( &_lockTable->lock );
+ return _lockTable;
+}
+
+static void
+lock_table_unlock( LockTable* t )
+{
+ pthread_mutex_unlock( &t->lock );
+}
+
+static FileLock**
+lock_table_lookup( LockTable* t, FILE* f )
+{
+ uint32_t hash = (uint32_t)(void*)f;
+ FileLock** pnode;
+
+ hash = (hash >> 2) ^ (hash << 17);
+ pnode = &t->buckets[hash % FILE_LOCK_BUCKETS];
+ for (;;) {
+ FileLock* node = *pnode;
+ if (node == NULL || node->file == f)
+ break;
+ pnode = &node->next;
+ }
+ return pnode;
+}
+
+void
+flockfile(FILE * fp)
+{
+ LockTable* t = lock_table_lock();
+
+ if (t != NULL) {
+ FileLock** lookup = lock_table_lookup(t, fp);
+ FileLock* lock = *lookup;
+
+ if (lock == NULL) {
+ pthread_mutexattr_t attr;
+
+ /* create a new node in the hash table */
+ lock = malloc(sizeof(*lock));
+ if (lock == NULL) {
+ lock_table_unlock(t);
+ return;
+ }
+ lock->next = NULL;
+ lock->file = fp;
+
+ pthread_mutexattr_init(&attr);
+ pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+ pthread_mutex_init( &lock->mutex, &attr );
+
+ *lookup = lock;
+ }
+ lock_table_unlock(t);
+
+ /* we assume that another thread didn't destroy 'lock'
+ * by calling fclose() on the FILE*. This can happen if
+ * the client is *really* buggy, but we don't care about
+ * such code here.
+ */
+ pthread_mutex_lock(&lock->mutex);
+ }
+}
+
+
+int
+ftrylockfile(FILE *fp)
+{
+ int ret = -1;
+ LockTable* t = lock_table_lock();
+
+ if (t != NULL) {
+ FileLock** lookup = lock_table_lookup(t, fp);
+ FileLock* lock = *lookup;
+
+ lock_table_unlock(t);
+
+ /* see above comment about why we assume that 'lock' can
+ * be accessed from here
+ */
+ if (lock != NULL && !pthread_mutex_trylock(&lock->mutex)) {
+ ret = 0; /* signal success */
+ }
+ }
+ return ret;
+}
+
+void
+funlockfile(FILE * fp)
+{
+ LockTable* t = lock_table_lock();
+
+ if (t != NULL) {
+ FileLock** lookup = lock_table_lookup(t, fp);
+ FileLock* lock = *lookup;
+
+ if (lock != NULL)
+ pthread_mutex_unlock(&lock->mutex);
+
+ lock_table_unlock(t);
+ }
+}
+
+
+/* called from fclose() to remove the file lock */
+void
+__fremovelock(FILE* fp)
+{
+ LockTable* t = lock_table_lock();
+
+ if (t != NULL) {
+ FileLock** lookup = lock_table_lookup(t, fp);
+ FileLock* lock = *lookup;
+
+ if (lock != NULL) {
+ *lookup = lock->next;
+ lock->file = NULL;
+ }
+ lock_table_unlock(t);
+
+ if (lock != NULL)
+ free(lock);
+ }
+}
diff --git a/libc/stdlib/div.c b/libc/stdlib/div.c
new file mode 100644
index 0000000..f7ac2db
--- /dev/null
+++ b/libc/stdlib/div.c
@@ -0,0 +1,71 @@
+/* $OpenBSD: div.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */
+/*
+ * Copyright (c) 1990 Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * 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.
+ */
+
+#include <stdlib.h> /* div_t */
+
+div_t
+div(int num, int denom)
+{
+ div_t r;
+
+ r.quot = num / denom;
+ r.rem = num % denom;
+ /*
+ * The ANSI standard says that |r.quot| <= |n/d|, where
+ * n/d is to be computed in infinite precision. In other
+ * words, we should always truncate the quotient towards
+ * 0, never -infinity.
+ *
+ * Machine division and remainer may work either way when
+ * one or both of n or d is negative. If only one is
+ * negative and r.quot has been truncated towards -inf,
+ * r.rem will have the same sign as denom and the opposite
+ * sign of num; if both are negative and r.quot has been
+ * truncated towards -inf, r.rem will be positive (will
+ * have the opposite sign of num). These are considered
+ * `wrong'.
+ *
+ * If both are num and denom are positive, r will always
+ * be positive.
+ *
+ * This all boils down to:
+ * if num >= 0, but r.rem < 0, we got the wrong answer.
+ * In that case, to get the right answer, add 1 to r.quot and
+ * subtract denom from r.rem.
+ */
+ if (num >= 0 && r.rem < 0) {
+ r.quot++;
+ r.rem -= denom;
+ }
+ return (r);
+}
diff --git a/libc/stdlib/ldiv.c b/libc/stdlib/ldiv.c
new file mode 100644
index 0000000..775065f
--- /dev/null
+++ b/libc/stdlib/ldiv.c
@@ -0,0 +1,50 @@
+/* $OpenBSD: ldiv.c,v 1.5 2005/08/08 08:05:36 espie Exp $ */
+/*
+ * Copyright (c) 1990 Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * 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.
+ */
+
+#include <stdlib.h> /* ldiv_t */
+
+ldiv_t
+ldiv(long num, long denom)
+{
+ ldiv_t r;
+
+ /* see div.c for comments */
+
+ r.quot = num / denom;
+ r.rem = num % denom;
+ if (num >= 0 && r.rem < 0) {
+ r.quot++;
+ r.rem -= denom;
+ }
+ return (r);
+}
diff --git a/libc/stdlib/lldiv.c b/libc/stdlib/lldiv.c
new file mode 100644
index 0000000..e8d6c97
--- /dev/null
+++ b/libc/stdlib/lldiv.c
@@ -0,0 +1,50 @@
+/* $OpenBSD: lldiv.c,v 1.1 2006/01/13 17:58:09 millert Exp $ */
+/*
+ * Copyright (c) 1990 Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * 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.
+ */
+
+#include <stdlib.h> /* lldiv_t */
+
+lldiv_t
+lldiv(long long num, long long denom)
+{
+ lldiv_t r;
+
+ /* see div.c for comments */
+
+ r.quot = num / denom;
+ r.rem = num % denom;
+ if (num >= 0 && r.rem < 0) {
+ r.quot++;
+ r.rem -= denom;
+ }
+ return (r);
+}
diff --git a/libc/tools/bionic_utils.py b/libc/tools/bionic_utils.py
index feb1561..65ff042 100644
--- a/libc/tools/bionic_utils.py
+++ b/libc/tools/bionic_utils.py
@@ -136,6 +136,11 @@ class SysCallsTxtParser:
print "%d: %s" % (self.lineno, msg)
def parse_line(self, line):
+ """ parse a syscall spec line.
+
+ line processing, format is
+ return type func_name[:syscall_name[:call_id]] ( [paramlist] ) (syscall_number[,syscall_number_x86])|stub
+ """
pos_lparen = line.find('(')
E = self.E
if pos_lparen < 0:
@@ -154,6 +159,7 @@ class SysCallsTxtParser:
syscall_func = return_type[-1]
return_type = string.join(return_type[:-1],' ')
+ call_id = -1
pos_colon = syscall_func.find(':')
if pos_colon < 0:
@@ -162,8 +168,20 @@ class SysCallsTxtParser:
if pos_colon == 0 or pos_colon+1 >= len(syscall_func):
E("misplaced colon in '%s'" % line)
return
- syscall_name = syscall_func[pos_colon+1:]
- syscall_func = syscall_func[:pos_colon]
+
+ # now find if there is a call_id for a dispatch-type syscall
+ # after the optional 2nd colon
+ pos_colon2 = syscall_func.find(':', pos_colon + 1)
+ if pos_colon2 < 0:
+ syscall_name = syscall_func[pos_colon+1:]
+ syscall_func = syscall_func[:pos_colon]
+ else:
+ if pos_colon2+1 >= len(syscall_func):
+ E("misplaced colon2 in '%s'" % line)
+ return
+ syscall_name = syscall_func[(pos_colon+1):pos_colon2]
+ call_id = int(syscall_func[pos_colon2+1:])
+ syscall_func = syscall_func[:pos_colon]
if pos_rparen > pos_lparen+1:
syscall_params = line[pos_lparen+1:pos_rparen].split(',')
@@ -191,6 +209,7 @@ class SysCallsTxtParser:
t = { "id" : syscall_id,
"id2" : syscall_id2,
+ "cid" : call_id,
"name" : syscall_name,
"func" : syscall_func,
"params" : syscall_params,
diff --git a/libc/tools/gensyscalls.py b/libc/tools/gensyscalls.py
index 37e356d..530e565 100755
--- a/libc/tools/gensyscalls.py
+++ b/libc/tools/gensyscalls.py
@@ -5,7 +5,7 @@
# of arch-x86/linux/_syscalls.h
#
-import sys, os.path, glob, re, string, commands, filecmp, shutil
+import sys, os.path, glob, re, commands, filecmp, shutil
from bionic_utils import *
@@ -196,7 +196,7 @@ class State:
self.other_files = []
self.syscalls = []
- def x86_genstub(self,fname, numparams, idname):
+ def x86_genstub(self, fname, numparams, idname):
t = { "fname" : fname,
"idname" : idname }
@@ -217,6 +217,43 @@ class State:
result += x86_return
return result
+ def x86_genstub_cid(self, fname, numparams, idname, cid):
+ # We'll ignore numparams here because in reality, if there is a
+ # dispatch call (like a socketcall syscall) there are actually
+ # only 2 arguments to the syscall and 2 regs we have to save:
+ # %ebx <--- Argument 1 - The call id of the needed vectored
+ # syscall (socket, bind, recv, etc)
+ # %ecx <--- Argument 2 - Pointer to the rest of the arguments
+ # from the original function called (socket())
+ t = { "fname" : fname,
+ "idname" : idname }
+
+ result = x86_header % t
+ stack_bias = 4
+
+ # save the regs we need
+ result += " pushl %ebx" + "\n"
+ stack_bias += 4
+ result += " pushl %ecx" + "\n"
+ stack_bias += 4
+
+ # set the call id (%ebx)
+ result += " mov $%d, %%ebx" % (cid) + "\n"
+
+ # set the pointer to the rest of the args into %ecx
+ result += " mov %esp, %ecx" + "\n"
+ result += " addl $%d, %%ecx" % (stack_bias) + "\n"
+
+ # now do the syscall code itself
+ result += x86_call % t
+
+ # now restore the saved regs
+ result += " popl %ecx" + "\n"
+ result += " popl %ebx" + "\n"
+
+ # epilog
+ result += x86_return
+ return result
def arm_genstub(self,fname, flags, idname):
t = { "fname" : fname,
@@ -269,7 +306,15 @@ class State:
t["asm-arm"] = self.arm_genstub(syscall_func,len(syscall_params),"__NR_"+syscall_name)
if t["id2"] >= 0:
- t["asm-x86"] = self.x86_genstub(syscall_func,len(syscall_params),"__NR_"+syscall_name)
+ if t["cid"] >= 0:
+ t["asm-x86"] = self.x86_genstub_cid(syscall_func, len(syscall_params), "__NR_"+syscall_name, t["cid"])
+ else:
+ t["asm-x86"] = self.x86_genstub(syscall_func,len(syscall_params),"__NR_"+syscall_name)
+ elif t["cid"] >= 0:
+ E("cid for dispatch syscalls is only supported for x86 in "
+ "'%s'" % syscall_name)
+ return
+
def gen_NR_syscall(self,fp,name,id):
fp.write( "#define __NR_%-25s (__NR_SYSCALL_BASE + %d)\n" % (name,id) )
@@ -306,14 +351,16 @@ class State:
self.gen_NR_syscall( fp, sc_name, sc_id )
fp.write( "#endif\n" );
+ gen_syscalls = {}
# finally, all i386-specific syscalls
fp.write( "\n#ifdef __i386__\n" );
for sc in self.syscalls:
sc_id = sc["id"]
sc_id2 = sc["id2"]
sc_name = sc["name"]
- if sc_id != sc_id2 and sc_id2 >= 0:
+ if sc_id != sc_id2 and sc_id2 >= 0 and sc_name not in gen_syscalls:
self.gen_NR_syscall( fp, sc_name, sc_id2 )
+ gen_syscalls[sc_name] = True
fp.write( "#endif\n" );
fp.write( "\n#endif\n" )
@@ -340,22 +387,28 @@ class State:
self.other_files.append( path )
# now dump the contents of syscalls.mk
- def gen_arch_arm_syscalls_mk(self):
- path = "arch-arm/syscalls.mk"
+ def gen_arch_syscalls_mk(self, arch):
+ path = "arch-%s/syscalls.mk" % arch
D( "generating "+path )
fp = create_file( path )
fp.write( "# auto-generated by gensyscalls.py, do not touch\n" )
fp.write( "syscall_src := \n" )
+ arch_test = {
+ "arm": lambda x: x.has_key("asm-arm") or x.has_key("asm-thumb"),
+ "x86": lambda x: x.has_key("asm-x86")
+ }
+
for sc in self.syscalls:
- if sc["id"] >= 0:
- fp.write( "syscall_src += arch-arm/syscalls/%s.S\n" % sc["func"] )
+ if arch_test[arch](sc):
+ fp.write("syscall_src += arch-%s/syscalls/%s.S\n" %
+ (arch, sc["func"]))
fp.close()
self.other_files.append( path )
# now generate each syscall stub
def gen_syscall_stubs(self):
for sc in self.syscalls:
- if sc.has_key("asm-arm"):
+ if sc.has_key("asm-arm") and 'arm' in all_archs:
fname = "arch-arm/syscalls/%s.S" % sc["func"]
D( ">>> generating "+fname )
fp = create_file( fname )
@@ -363,7 +416,7 @@ class State:
fp.close()
self.new_stubs.append( fname )
- if sc.has_key("asm-thumb"):
+ if sc.has_key("asm-thumb") and 'arm' in all_archs:
fname = "arch-arm/syscalls/%s.S" % sc["func"]
D( ">>> generating "+fname )
fp = create_file( fname )
@@ -371,7 +424,7 @@ class State:
fp.close()
self.new_stubs.append( fname )
- if sc.has_key("asm-x86"):
+ if sc.has_key("asm-x86") and 'x86' in all_archs:
fname = "arch-x86/syscalls/%s.S" % sc["func"]
D( ">>> generating "+fname )
fp = create_file( fname )
@@ -407,7 +460,8 @@ class State:
D( "re-generating stubs and support files" )
self.gen_linux_syscalls_h()
- self.gen_arch_arm_syscalls_mk()
+ for arch in all_archs:
+ self.gen_arch_syscalls_mk(arch)
self.gen_linux_unistd_h()
self.gen_syscall_stubs()
@@ -434,11 +488,12 @@ class State:
if adds:
- commands.getoutput( "p4 add " + string.join( adds, " " ) )
+ commands.getoutput("p4 add " + " ".join(adds))
if deletes:
- commands.getoutput( "p4 delete " + string.join( deletes, " " ) )
+ commands.getoutput("p4 delete " + " ".join(deletes))
if edits:
- commands.getoutput( "p4 edit " + string.join( edits, " " ) )
+ commands.getoutput("p4 edit " +
+ " ".join((bionic_root + file) for file in edits))
for file in edits:
shutil.copyfile( bionic_temp + file, bionic_root + file )
diff --git a/libc/unistd/ftime.c b/libc/unistd/ftime.c
new file mode 100644
index 0000000..6513593
--- /dev/null
+++ b/libc/unistd/ftime.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * 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.
+ *
+ * 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
+ * COPYRIGHT OWNER 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.
+ */
+#include <sys/timeb.h>
+
+int ftime(struct timeb *tb)
+{
+ struct timeval tv;
+ struct timezone tz;
+
+ if (gettimeofday (&tv, &tz) < 0)
+ return -1;
+
+ tb->time = tv.tv_sec;
+ tb->millitm = (tv.tv_usec + 500) / 1000;
+
+ if (tb->millitm == 1000) {
+ ++tb->time;
+ tb->millitm = 0;
+ }
+ tb->timezone = tz.tz_minuteswest;
+ tb->dstflag = tz.tz_dsttime;
+
+ return 0;
+}
diff --git a/libc/unistd/initgroups.c b/libc/unistd/initgroups.c
new file mode 100644
index 0000000..dea6d96
--- /dev/null
+++ b/libc/unistd/initgroups.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * 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.
+ *
+ * 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
+ * COPYRIGHT OWNER 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.
+ */
+#include <grp.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#define INIT_GROUPS 2
+
+int
+initgroups (const char *user, gid_t group)
+{
+ gid_t groups0[ INIT_GROUPS ];
+ gid_t* groups = groups0;
+ int ret = -1;
+ int numgroups = INIT_GROUPS;
+
+ if (getgrouplist(user, group, groups, &numgroups) < 0) {
+ groups = malloc(numgroups*sizeof(groups[0]));
+ if (groups == NULL)
+ return -1;
+ if (getgrouplist(user,group,groups,&numgroups) < 0) {
+ goto EXIT;
+ }
+ }
+
+ ret = setgroups(numgroups, groups);
+
+EXIT:
+ if (groups != groups0)
+ free(groups);
+
+ return ret;
+}
diff --git a/libc/unistd/opendir.c b/libc/unistd/opendir.c
index 1b06057..afa3ea0 100644
--- a/libc/unistd/opendir.c
+++ b/libc/unistd/opendir.c
@@ -203,3 +203,65 @@ void rewinddir(DIR *dir)
pthread_mutex_unlock( &dir->_DIR_lock );
}
+
+int alphasort(const void *a, const void *b)
+{
+ struct dirent **d1, **d2;
+
+ d1 = (struct dirent **) a;
+ d2 = (struct dirent **) b;
+ return strcmp((*d1)->d_name, (*d2)->d_name);
+}
+
+
+int scandir(const char *dir, struct dirent ***namelist,
+ int(*filter)(const struct dirent *),
+ int(*compar)(const struct dirent **, const struct dirent **))
+{
+ DIR *d;
+ int n_elem = 0;
+ struct dirent *this_de, *de;
+ struct dirent **de_list = NULL;
+ int de_list_size = 0;
+
+ d = opendir(dir);
+ if (d == NULL) {
+ return -1;
+ }
+
+ while ((this_de = readdir(d)) != NULL) {
+ if (filter && (*filter)(this_de) == 0) {
+ continue;
+ }
+ if (n_elem == 0) {
+ de_list_size = 4;
+ de_list = (struct dirent **)
+ malloc(sizeof(struct dirent *)*de_list_size);
+ if (de_list == NULL) {
+ return -1;
+ }
+ }
+ else if (n_elem == de_list_size) {
+ struct dirent **de_list_new;
+
+ de_list_size += 10;
+ de_list_new = (struct dirent **)
+ realloc(de_list, sizeof(struct dirent *)*de_list_size);
+ if (de_list_new == NULL) {
+ free(de_list);
+ return -1;
+ }
+ de_list = de_list_new;
+ }
+ de = (struct dirent *) malloc(sizeof(struct dirent));
+ *de = *this_de;
+ de_list[n_elem++] = de;
+ }
+ closedir(d);
+ if (n_elem && compar) {
+ qsort(de_list, n_elem, sizeof(struct dirent *),
+ (int (*)(const void *, const void *)) compar);
+ }
+ *namelist = de_list;
+ return n_elem;
+}
diff --git a/libc/unistd/pread.c b/libc/unistd/pread.c
index 7bfaeaa..d2f71f7 100644
--- a/libc/unistd/pread.c
+++ b/libc/unistd/pread.c
@@ -11,39 +11,24 @@
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
+ * 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 Google 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
- * COPYRIGHT OWNER 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.
- */
+*/
#include <sys/types.h>
#include <unistd.h>
-#include <errno.h>
-/*
- * Non-atomic emulation of the pread system call.
- */
-ssize_t pread(int fd, void *buf, size_t count, off_t offset)
+extern int __pread64(int fd, void *buf, size_t nbytes, off_t lo, off_t hi);
+
+ssize_t pread(int fd, void *buf, size_t nbytes, off_t offset)
{
- int save_errno;
- ssize_t nread;
- off_t save_offset = lseek(fd, offset, SEEK_SET);
- if (save_offset < 0) {
- return -1;
- }
- nread = read(fd, buf, count);
- save_errno = errno;
- /* Even if the read failed, try to restore the seek pointer */
- lseek(fd, save_offset, SEEK_SET);
- errno = save_errno;
- return nread;
+ return __pread64(fd, buf, nbytes, offset, 0);
}
+
diff --git a/libc/unistd/pwrite.c b/libc/unistd/pwrite.c
index 7f5e071..5adf40a 100644
--- a/libc/unistd/pwrite.c
+++ b/libc/unistd/pwrite.c
@@ -27,23 +27,11 @@
*/
#include <sys/types.h>
#include <unistd.h>
-#include <errno.h>
-/*
- * Non-atomic emulation of the pwrite system call.
- */
-ssize_t pwrite(int fd, void *buf, size_t count, off_t offset)
+extern int __pwrite64(int fd, void *buf, size_t nbytes, off_t lo, off_t hi);
+
+ssize_t pwrite(int fd, void *buf, size_t nbytes, off_t offset)
{
- int save_errno;
- ssize_t nwrite;
- off_t save_offset = lseek(fd, offset, SEEK_SET);
- if (save_offset < 0) {
- return -1;
- }
- nwrite = write(fd, buf, count);
- save_errno = errno;
- /* Even if the write failed, try to restore the seek pointer */
- lseek(fd, save_offset, SEEK_SET);
- errno = save_errno;
- return nwrite;
+ return __pwrite64(fd, buf, nbytes, offset, 0);
}
+
diff --git a/libc/unistd/siginterrupt.c b/libc/unistd/siginterrupt.c
new file mode 100644
index 0000000..4e91edb
--- /dev/null
+++ b/libc/unistd/siginterrupt.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * 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.
+ *
+ * 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
+ * COPYRIGHT OWNER 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.
+ */
+
+#include <signal.h>
+
+/* this is only useful for legacy programs */
+int siginterrupt(int sig, int flag)
+{
+ struct sigaction act;
+
+ (void) sigaction(sig, NULL, &act);
+
+ if (flag)
+ act.sa_flags &= ~SA_RESTART;
+ else
+ act.sa_flags |= SA_RESTART;
+
+ return sigaction(sig, &act, NULL);
+}
+
diff --git a/libc/unistd/tcgetpgrp.c b/libc/unistd/tcgetpgrp.c
new file mode 100644
index 0000000..4355014
--- /dev/null
+++ b/libc/unistd/tcgetpgrp.c
@@ -0,0 +1,34 @@
+/* bionic/unistd/tcgetpgrp.c
+**
+** Copyright 2006, The Android Open Source Project
+**
+** Redistribution and use in source and binary forms, with or without
+** 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 Google 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 Google Inc. ``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 Google Inc. 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.
+*/
+#include <unistd.h>
+#include <termios.h>
+
+pid_t tcgetpgrp(int fd)
+{
+ pid_t _pid;
+ return ioctl(fd, TIOCGPGRP, &_pid) ? (pid_t)-1 : _pid;
+}
diff --git a/libc/unistd/tcsetpgrp.c b/libc/unistd/tcsetpgrp.c
new file mode 100644
index 0000000..b83b997
--- /dev/null
+++ b/libc/unistd/tcsetpgrp.c
@@ -0,0 +1,33 @@
+/* bionic/unistd/tcsetpgrp.c
+**
+** Copyright 2006, The Android Open Source Project
+**
+** Redistribution and use in source and binary forms, with or without
+** 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 Google 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 Google Inc. ``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 Google Inc. 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.
+*/
+#include <unistd.h>
+#include <termios.h>
+
+int tcsetpgrp(int fd, pid_t _pid)
+{
+ return ioctl(fd, TIOCSPGRP, &_pid);
+}
diff --git a/libc/zoneinfo/Android.mk b/libc/zoneinfo/Android.mk
index b2bec37..2f36f9b 100644
--- a/libc/zoneinfo/Android.mk
+++ b/libc/zoneinfo/Android.mk
@@ -8,3 +8,7 @@ $(TARGET_OUT)/usr/share/zoneinfo/zoneinfo.dat : $(LOCAL_PATH)/zoneinfo.dat | $(A
ALL_PREBUILT += $(TARGET_OUT)/usr/share/zoneinfo/zoneinfo.idx
$(TARGET_OUT)/usr/share/zoneinfo/zoneinfo.idx : $(LOCAL_PATH)/zoneinfo.idx | $(ACP)
$(transform-prebuilt-to-target)
+
+ALL_PREBUILT += $(TARGET_OUT)/usr/share/zoneinfo/zoneinfo.version
+$(TARGET_OUT)/usr/share/zoneinfo/zoneinfo.version : $(LOCAL_PATH)/zoneinfo.version | $(ACP)
+ $(transform-prebuilt-to-target)
diff --git a/libc/zoneinfo/zoneinfo.dat b/libc/zoneinfo/zoneinfo.dat
index dab27e9..e5bf25a 100644
--- a/libc/zoneinfo/zoneinfo.dat
+++ b/libc/zoneinfo/zoneinfo.dat
Binary files differ
diff --git a/libc/zoneinfo/zoneinfo.idx b/libc/zoneinfo/zoneinfo.idx
index 52d4d9e..78a3650 100644
--- a/libc/zoneinfo/zoneinfo.idx
+++ b/libc/zoneinfo/zoneinfo.idx
Binary files differ
diff --git a/libc/zoneinfo/zoneinfo.version b/libc/zoneinfo/zoneinfo.version
new file mode 100644
index 0000000..289c5d1
--- /dev/null
+++ b/libc/zoneinfo/zoneinfo.version
@@ -0,0 +1 @@
+2007h
diff --git a/libdl/Android.mk b/libdl/Android.mk
index 661aa18..150f704 100644
--- a/libdl/Android.mk
+++ b/libdl/Android.mk
@@ -16,6 +16,14 @@ include $(CLEAR_VARS)
# DO NOT REMOVE --exclude-libs!
LOCAL_LDFLAGS := -Wl,--exclude-libs=libgcc.a
+
+# for x86, exclude libgcc_eh.a for the same reasons as above
+ifneq ($(TARGET_SIMULATOR),true)
+ifeq ($(TARGET_ARCH),x86)
+LOCAL_LDFLAGS += -Wl,--exclude-libs=libgcc_eh.a
+endif
+endif
+
LOCAL_SRC_FILES:= libdl.c
LOCAL_MODULE:= libdl
diff --git a/libdl/libdl.c b/libdl/libdl.c
index 0411623..52707f1 100644
--- a/libdl/libdl.c
+++ b/libdl/libdl.c
@@ -21,4 +21,14 @@ void *dlopen(const char *filename, int flag) { return 0; }
char *dlerror(void) { return 0; }
void *dlsym(void *handle, const char *symbol) { return 0; }
int dlclose(void *handle) { return 0; }
+
+#ifdef __arm__
void *dl_unwind_find_exidx(void *pc, int *pcount) { return 0; }
+#elif defined(__i386__)
+/* we munge the cb definition so we don't have to include any headers here.
+ * It won't affect anything since these are just symbols anyway */
+int dl_iterate_phdr(int (*cb)(void *info, void *size, void *data),
+ void *data) { return 0; }
+#else
+#error Unsupported architecture. Only arm and x86 are supported.
+#endif
diff --git a/libm/Android.mk b/libm/Android.mk
index 5f0922d..8f0c3b1 100644
--- a/libm/Android.mk
+++ b/libm/Android.mk
@@ -2,7 +2,7 @@ LOCAL_PATH:= $(call my-dir)
libm_common_src_files:= \
isinf.c \
- fpclassify.c \
+ fpclassify.c \
bsdsrc/b_exp.c \
bsdsrc/b_log.c \
bsdsrc/b_tgamma.c \
@@ -54,7 +54,6 @@ libm_common_src_files:= \
src/e_sinhf.c \
src/e_sqrt.c \
src/e_sqrtf.c \
- arm/fenv.c \
src/k_cos.c \
src/k_cosf.c \
src/k_rem_pio2.c \
@@ -128,9 +127,6 @@ libm_common_src_files:= \
src/s_round.c \
src/s_roundf.c \
src/s_roundl.c \
- src/s_scalbln.c \
- src/s_scalbn.c \
- src/s_scalbnf.c \
src/s_signbit.c \
src/s_signgam.c \
src/s_significand.c \
@@ -153,6 +149,32 @@ libm_common_src_files:= \
src/s_isnan.c \
src/s_modf.c
+
+ifeq ($(TARGET_ARCH),arm)
+ libm_common_src_files += \
+ arm/fenv.c \
+ src/e_ldexpf.c \
+ src/s_scalbln.c \
+ src/s_scalbn.c \
+ src/s_scalbnf.c
+
+ libm_common_includes = $(LOCAL_PATH)/arm
+
+else
+ ifeq ($(TARGET_OS)-$(TARGET_ARCH),linux-x86)
+ libm_common_src_files += \
+ i387/fenv.c \
+ i387/s_scalbnl.S \
+ i387/s_scalbn.S \
+ i387/s_scalbnf.S
+
+ libm_common_includes = $(LOCAL_PATH)/i386 $(LOCAL_PATH)/i387
+ else
+ $(error "Unknown architecture")
+ endif
+endif
+
+
# libm.a
# ========================================================
@@ -162,7 +184,7 @@ LOCAL_SRC_FILES := \
$(libm_common_src_files)
LOCAL_ARM_MODE := arm
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/arm
+LOCAL_C_INCLUDES += $(libm_common_includes)
LOCAL_MODULE:= libm
@@ -180,7 +202,7 @@ LOCAL_SRC_FILES := \
LOCAL_ARM_MODE := arm
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/arm
+LOCAL_C_INCLUDES += $(libm_common_includes)
LOCAL_MODULE:= libm
diff --git a/libm/i387/fenv.c b/libm/i387/fenv.c
index 830e38f..2794faf 100644
--- a/libm/i387/fenv.c
+++ b/libm/i387/fenv.c
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#include <sys/types.h>
-#include <machine/npx.h>
+#include "npx.h"
#include "fenv.h"
const fenv_t __fe_dfl_env = {
diff --git a/libm/i387/npx.h b/libm/i387/npx.h
new file mode 100644
index 0000000..38c2add
--- /dev/null
+++ b/libm/i387/npx.h
@@ -0,0 +1,160 @@
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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.
+ * 4. 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.
+ *
+ * from: @(#)npx.h 5.3 (Berkeley) 1/18/91
+ * $FreeBSD: src/sys/i386/include/npx.h,v 1.29.2.1 2006/07/01 00:57:55 davidxu Exp $
+ */
+
+/*
+ * 287/387 NPX Coprocessor Data Structures and Constants
+ * W. Jolitz 1/90
+ */
+
+#ifndef _MACHINE_NPX_H_
+#define _MACHINE_NPX_H_
+
+/* Environment information of floating point unit */
+struct env87 {
+ long en_cw; /* control word (16bits) */
+ long en_sw; /* status word (16bits) */
+ long en_tw; /* tag word (16bits) */
+ long en_fip; /* floating point instruction pointer */
+ u_short en_fcs; /* floating code segment selector */
+ u_short en_opcode; /* opcode last executed (11 bits ) */
+ long en_foo; /* floating operand offset */
+ long en_fos; /* floating operand segment selector */
+};
+
+/* Contents of each floating point accumulator */
+struct fpacc87 {
+#ifdef dontdef /* too unportable */
+ u_long fp_mantlo; /* mantissa low (31:0) */
+ u_long fp_manthi; /* mantissa high (63:32) */
+ int fp_exp:15; /* exponent */
+ int fp_sgn:1; /* mantissa sign */
+#else
+ u_char fp_bytes[10];
+#endif
+};
+
+/* Floating point context */
+struct save87 {
+ struct env87 sv_env; /* floating point control/status */
+ struct fpacc87 sv_ac[8]; /* accumulator contents, 0-7 */
+ u_char sv_pad0[4]; /* padding for (now unused) saved status word */
+ /*
+ * Bogus padding for emulators. Emulators should use their own
+ * struct and arrange to store into this struct (ending here)
+ * before it is inspected for ptracing or for core dumps. Some
+ * emulators overwrite the whole struct. We have no good way of
+ * knowing how much padding to leave. Leave just enough for the
+ * GPL emulator's i387_union (176 bytes total).
+ */
+ u_char sv_pad[64]; /* padding; used by emulators */
+};
+
+struct envxmm {
+ u_int16_t en_cw; /* control word (16bits) */
+ u_int16_t en_sw; /* status word (16bits) */
+ u_int16_t en_tw; /* tag word (16bits) */
+ u_int16_t en_opcode; /* opcode last executed (11 bits ) */
+ u_int32_t en_fip; /* floating point instruction pointer */
+ u_int16_t en_fcs; /* floating code segment selector */
+ u_int16_t en_pad0; /* padding */
+ u_int32_t en_foo; /* floating operand offset */
+ u_int16_t en_fos; /* floating operand segment selector */
+ u_int16_t en_pad1; /* padding */
+ u_int32_t en_mxcsr; /* SSE sontorol/status register */
+ u_int32_t en_mxcsr_mask; /* valid bits in mxcsr */
+};
+
+/* Contents of each SSE extended accumulator */
+struct xmmacc {
+ u_char xmm_bytes[16];
+};
+
+struct savexmm {
+ struct envxmm sv_env;
+ struct {
+ struct fpacc87 fp_acc;
+ u_char fp_pad[6]; /* padding */
+ } sv_fp[8];
+ struct xmmacc sv_xmm[8];
+ u_char sv_pad[224];
+} __aligned(16);
+
+union savefpu {
+ struct save87 sv_87;
+ struct savexmm sv_xmm;
+};
+
+/*
+ * The hardware default control word for i387's and later coprocessors is
+ * 0x37F, giving:
+ *
+ * round to nearest
+ * 64-bit precision
+ * all exceptions masked.
+ *
+ * We modify the affine mode bit and precision bits in this to give:
+ *
+ * affine mode for 287's (if they work at all) (1 in bitfield 1<<12)
+ * 53-bit precision (2 in bitfield 3<<8)
+ *
+ * 64-bit precision often gives bad results with high level languages
+ * because it makes the results of calculations depend on whether
+ * intermediate values are stored in memory or in FPU registers.
+ */
+#define __INITIAL_NPXCW__ 0x127F
+#define __INITIAL_MXCSR__ 0x1F80
+
+#ifdef _KERNEL
+
+#define IO_NPX 0x0F0 /* Numeric Coprocessor */
+#define IO_NPXSIZE 16 /* 80387/80487 NPX registers */
+
+#define IRQ_NPX 13
+
+/* full reset on some systems, NOP on others */
+#define npx_full_reset() outb(IO_NPX + 1, 0)
+
+int npxdna(void);
+void npxdrop(void);
+void npxexit(struct thread *td);
+int npxformat(void);
+int npxgetregs(struct thread *td, union savefpu *addr);
+void npxinit(u_short control);
+void npxsave(union savefpu *addr);
+void npxsetregs(struct thread *td, union savefpu *addr);
+int npxtrap(void);
+#endif
+
+#endif /* !_MACHINE_NPX_H_ */
diff --git a/libm/src/e_ldexpf.c b/libm/src/e_ldexpf.c
new file mode 100644
index 0000000..86297fc
--- /dev/null
+++ b/libm/src/e_ldexpf.c
@@ -0,0 +1,22 @@
+/* e_scalbf.c -- float version of e_scalb.c.
+ * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+ */
+
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+#include "math.h"
+#include "math_private.h"
+
+float
+__ieee754_ldexpf(float x, int fn)
+{
+ return __ieee754_scalbf(x,fn);
+}
diff --git a/libm/src/math_private.h b/libm/src/math_private.h
index 13bcd3a..5f6e088 100644
--- a/libm/src/math_private.h
+++ b/libm/src/math_private.h
@@ -254,6 +254,7 @@ cpackl(long double x, long double y)
#define __ieee754_ynf ynf
#define __ieee754_remainderf remainderf
#define __ieee754_scalbf scalbf
+#define __ieee754_ldexpf ldexpf
/* fdlibm kernel function */
int __ieee754_rem_pio2(double,double*);
diff --git a/libc/include/stl_pair.h b/libstdc++/include/stl_pair.h
index 08180b0..37f757b 100644
--- a/libc/include/stl_pair.h
+++ b/libstdc++/include/stl_pair.h
@@ -113,7 +113,7 @@ inline pair<_T1, _T2> make_pair(_T1 __x, _T2 __y)
return pair<_T1, _T2>(__x, __y);
}
-} // namespace std
+__STL_END_NAMESPACE
#endif /* __SGI_STL_INTERNAL_PAIR_H */
diff --git a/libc/include/utility b/libstdc++/include/utility
index 12044a7..12044a7 100644
--- a/libc/include/utility
+++ b/libstdc++/include/utility
diff --git a/linker/debugger.c b/linker/debugger.c
index 68997c5..542cf8d 100644
--- a/linker/debugger.c
+++ b/linker/debugger.c
@@ -16,20 +16,20 @@ void debugger_signal_handler(int n)
{
unsigned tid;
int s;
-
- /* avoid picking up GC interrupts */
+
+ /* avoid picking up GC interrupts */
signal(SIGUSR1, SIG_IGN);
-
+
tid = gettid();
s = socket_local_client("android:debuggerd",
ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_STREAM);
-
+
if(s >= 0) {
- /* debugger knows our pid from the credentials on the
- ** local socket but we need to tell it our tid. It
- ** is paranoid and will verify that we are giving a tid
- ** that's actually in our process
- */
+ /* debugger knows our pid from the credentials on the
+ * local socket but we need to tell it our tid. It
+ * is paranoid and will verify that we are giving a tid
+ * that's actually in our process
+ */
write(s, &tid, sizeof(unsigned));
read(s, &tid, 1);
@@ -37,7 +37,7 @@ void debugger_signal_handler(int n)
close(s);
}
- /* remove our net so we fault for real when we return */
+ /* remove our net so we fault for real when we return */
signal(n, SIG_IGN);
}
diff --git a/linker/linker.c b/linker/linker.c
index 88e3ea2..34ed80e 100644
--- a/linker/linker.c
+++ b/linker/linker.c
@@ -7,6 +7,7 @@
#include <fcntl.h>
#include <errno.h>
#include <dlfcn.h>
+#include <sys/stat.h>
//#include <pthread.h>
@@ -409,6 +410,21 @@ static const char *sopaths[] = {
0
};
+static int _open_lib(const char *name)
+{
+ int fd;
+ struct stat filestat;
+
+ if ((stat(name, &filestat) >= 0) && S_ISREG(filestat.st_mode)) {
+ if ((fd = open(name, O_RDONLY)) >= 0)
+ return fd;
+ }
+
+ return -1;
+}
+
+/* TODO: Need to add support for initializing the so search path with
+ * LD_LIBRARY_PATH env variable for non-setuid programs. */
static int open_library(const char *name)
{
int fd;
@@ -417,16 +433,16 @@ static int open_library(const char *name)
TRACE("[ %5d opening %s ]\n", pid, name);
- if(strlen(name) > 256) return -1;
if(name == 0) return -1;
+ if(strlen(name) > 256) return -1;
- fd = open(name, O_RDONLY);
- if(fd != -1) return fd;
+ if ((name[0] == '/') && ((fd = _open_lib(name)) >= 0))
+ return fd;
- for(path = sopaths; *path; path++){
- sprintf(buf,"%s/%s", *path, name);
- fd = open(buf, O_RDONLY);
- if(fd != -1) return fd;
+ for (path = sopaths; *path; path++) {
+ snprintf(buf, sizeof(buf), "%s/%s", *path, name);
+ if ((fd = _open_lib(buf)) >= 0)
+ return fd;
}
return -1;
@@ -1026,7 +1042,7 @@ unsigned unload_library(soinfo *si)
}
else {
si->refcount--;
- ERROR("%5d not unloading '%s', decrementing refcount to %d\n",
+ PRINT("%5d not unloading '%s', decrementing refcount to %d\n",
pid, si->name, si->refcount);
}
return si->refcount;
diff --git a/linker/linker_debug.h b/linker/linker_debug.h
index 10ae7b1..fa2a1a1 100644
--- a/linker/linker_debug.h
+++ b/linker/linker_debug.h
@@ -27,15 +27,17 @@
#define TRUE 1
#define FALSE 0
+
+#define __PRINTVF(v,f,x...) do { \
+ (debug_verbosity > (v)) && (printf(x), ((f) && fflush(stdout))); \
+ } while (0)
/* Only use printf() during debugging. We have seen occasional memory
* corruption when the linker uses printf().
*/
#if LINKER_DEBUG
extern int debug_verbosity;
#warning "*** LINKER IS USING printf(); DO NOT CHECK THIS IN ***"
-#define _PRINTVF(v,f,x...) do { \
- (debug_verbosity > (v)) && (printf(x), ((f) && fflush(stdout))); \
- } while (0)
+#define _PRINTVF(v,f,x...) __PRINTVF(v,f,x)
#else /* !LINKER_DEBUG */
#define _PRINTVF(v,f,x...) do {} while(0)
#endif /* LINKER_DEBUG */
@@ -46,7 +48,7 @@ extern int debug_verbosity;
#define WARN(fmt,args...) \
_PRINTVF(-1, TRUE, "%s:%d| WARNING: " fmt, __FILE__, __LINE__, ## args)
#define ERROR(fmt,args...) \
- _PRINTVF(-1, TRUE, "%s:%d| ERROR: " fmt, __FILE__, __LINE__, ## args)
+ __PRINTVF(-1, TRUE, "%s:%d| ERROR: " fmt, __FILE__, __LINE__, ## args)
#if TRACE_DEBUG
#define DEBUG(x...) _PRINTVF(2, TRUE, "DEBUG: " x)