Merge commit 'remotes/korg/cupcake'
Conflicts: libc/include/dirent.h
This commit is contained in:
commit
b675146ae7
174
libc/Android.mk
174
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,
|
||||
|
@ -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
|
||||
|
@ -1 +0,0 @@
|
||||
/tmp/bionic-kernel-headers/asm-arm
|
@ -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_ */
|
||||
|
@ -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
|
||||
|
@ -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
|
21
libc/arch-arm/syscalls/__pread64.S
Normal file
21
libc/arch-arm/syscalls/__pread64.S
Normal file
@ -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
|
21
libc/arch-arm/syscalls/__pwrite64.S
Normal file
21
libc/arch-arm/syscalls/__pwrite64.S
Normal file
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
19
libc/arch-arm/syscalls/getitimer.S
Normal file
19
libc/arch-arm/syscalls/getitimer.S
Normal file
@ -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
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
34
libc/arch-x86/bionic/_exit_with_stack_teardown.S
Normal file
34
libc/arch-x86/bionic/_exit_with_stack_teardown.S
Normal file
@ -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
|
71
libc/arch-x86/bionic/_setjmp.S
Normal file
71
libc/arch-x86/bionic/_setjmp.S
Normal file
@ -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
|
140
libc/arch-x86/bionic/atomics_x86.S
Normal file
140
libc/arch-x86/bionic/atomics_x86.S
Normal file
@ -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
|
||||
|
50
libc/arch-x86/bionic/clone.S
Normal file
50
libc/arch-x86/bionic/clone.S
Normal file
@ -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
|
96
libc/arch-x86/bionic/crtbegin_dynamic.S
Normal file
96
libc/arch-x86/bionic/crtbegin_dynamic.S
Normal file
@ -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
|
||||
|
29
libc/arch-x86/bionic/crtbegin_so.S
Normal file
29
libc/arch-x86/bionic/crtbegin_so.S
Normal file
@ -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
|
95
libc/arch-x86/bionic/crtbegin_static.S
Normal file
95
libc/arch-x86/bionic/crtbegin_static.S
Normal file
@ -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
|
||||
|
13
libc/arch-x86/bionic/crtend.S
Normal file
13
libc/arch-x86/bionic/crtend.S
Normal file
@ -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
|
||||
|
47
libc/arch-x86/bionic/crtend_so.S
Normal file
47
libc/arch-x86/bionic/crtend_so.S
Normal file
@ -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
|
74
libc/arch-x86/bionic/dl_iterate_phdr_static.c
Normal file
74
libc/arch-x86/bionic/dl_iterate_phdr_static.c
Normal file
@ -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);
|
||||
}
|
||||
|
93
libc/arch-x86/bionic/setjmp.S
Normal file
93
libc/arch-x86/bionic/setjmp.S
Normal file
@ -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
|
30
libc/arch-x86/bionic/vfork.S
Normal file
30
libc/arch-x86/bionic/vfork.S
Normal file
@ -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
|
@ -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_ */
|
||||
|
41
libc/arch-x86/include/machine/kernel.h
Normal file
41
libc/arch-x86/include/machine/kernel.h
Normal file
@ -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 */
|
171
libc/arch-x86/syscalls.mk
Normal file
171
libc/arch-x86/syscalls.mk
Normal file
@ -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
|
@ -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
|
35
libc/arch-x86/syscalls/__pread64.S
Normal file
35
libc/arch-x86/syscalls/__pread64.S
Normal file
@ -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
|
35
libc/arch-x86/syscalls/__pwrite64.S
Normal file
35
libc/arch-x86/syscalls/__pwrite64.S
Normal file
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
@ -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
|
27
libc/arch-x86/syscalls/accept.S
Normal file
27
libc/arch-x86/syscalls/accept.S
Normal file
@ -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
|
27
libc/arch-x86/syscalls/bind.S
Normal file
27
libc/arch-x86/syscalls/bind.S
Normal file
@ -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
|
27
libc/arch-x86/syscalls/connect.S
Normal file
27
libc/arch-x86/syscalls/connect.S
Normal file
@ -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
|
26
libc/arch-x86/syscalls/getitimer.S
Normal file
26
libc/arch-x86/syscalls/getitimer.S
Normal file
@ -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
|
27
libc/arch-x86/syscalls/getpeername.S
Normal file
27
libc/arch-x86/syscalls/getpeername.S
Normal file
@ -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
|
27
libc/arch-x86/syscalls/getsockname.S
Normal file
27
libc/arch-x86/syscalls/getsockname.S
Normal file
@ -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
|
27
libc/arch-x86/syscalls/getsockopt.S
Normal file
27
libc/arch-x86/syscalls/getsockopt.S
Normal file
@ -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
|
27
libc/arch-x86/syscalls/listen.S
Normal file
27
libc/arch-x86/syscalls/listen.S
Normal file
@ -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
|
27
libc/arch-x86/syscalls/recvfrom.S
Normal file
27
libc/arch-x86/syscalls/recvfrom.S
Normal file
@ -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
|
27
libc/arch-x86/syscalls/recvmsg.S
Normal file
27
libc/arch-x86/syscalls/recvmsg.S
Normal file
@ -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
|
27
libc/arch-x86/syscalls/sendmsg.S
Normal file
27
libc/arch-x86/syscalls/sendmsg.S
Normal file
@ -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
|
27
libc/arch-x86/syscalls/sendto.S
Normal file
27
libc/arch-x86/syscalls/sendto.S
Normal file
@ -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
|
27
libc/arch-x86/syscalls/setsockopt.S
Normal file
27
libc/arch-x86/syscalls/setsockopt.S
Normal file
@ -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
|
27
libc/arch-x86/syscalls/shutdown.S
Normal file
27
libc/arch-x86/syscalls/shutdown.S
Normal file
@ -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
|
27
libc/arch-x86/syscalls/socket.S
Normal file
27
libc/arch-x86/syscalls/socket.S
Normal file
@ -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
|
27
libc/arch-x86/syscalls/socketpair.S
Normal file
27
libc/arch-x86/syscalls/socketpair.S
Normal file
@ -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
|
@ -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
|
48
libc/bionic/fork.c
Normal file
48
libc/bionic/fork.c
Normal file
@ -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;
|
||||
}
|
63
libc/bionic/if_indextoname.c
Normal file
63
libc/bionic/if_indextoname.c
Normal file
@ -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;
|
||||
}
|
@ -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) {
|
||||
|
625
libc/bionic/pthread-timers.c
Normal file
625
libc/bionic/pthread-timers.c
Normal file
@ -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;
|
||||
}
|
@ -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,17 +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 status;
|
||||
int oldvalue = cond->value;
|
||||
|
||||
pthread_mutex_unlock(mutex);
|
||||
status = __futex_wait(&cond->value, oldvalue, reltime);
|
||||
pthread_mutex_lock(mutex);
|
||||
|
||||
if (status == (-ETIMEDOUT)) return ETIMEDOUT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
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_REALTIME, &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) {
|
||||
@ -1145,15 +1178,14 @@ int pthread_cond_timedwait(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);
|
||||
|
||||
if(status == (-ETIMEDOUT)) return ETIMEDOUT;
|
||||
|
||||
return 0;
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@ -1161,36 +1193,7 @@ int pthread_cond_timedwait_monotonic(pthread_cond_t *cond,
|
||||
pthread_mutex_t * mutex,
|
||||
const struct timespec *abstime)
|
||||
{
|
||||
int oldvalue;
|
||||
struct timespec ts;
|
||||
struct timespec * tsp;
|
||||
int status;
|
||||
|
||||
if (abstime != NULL) {
|
||||
clock_gettime(CLOCK_MONOTONIC, &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;
|
||||
|
||||
pthread_mutex_unlock(mutex);
|
||||
status = __futex_wait(&cond->value, oldvalue, tsp);
|
||||
pthread_mutex_lock(mutex);
|
||||
|
||||
if(status == (-ETIMEDOUT)) return ETIMEDOUT;
|
||||
|
||||
return 0;
|
||||
return __pthread_cond_timedwait(cond, mutex, abstime, CLOCK_MONOTONIC);
|
||||
}
|
||||
|
||||
int pthread_cond_timeout_np(pthread_cond_t *cond,
|
||||
|
@ -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_ */
|
||||
|
@ -73,6 +73,7 @@ extern int scandir(const char *dir, struct dirent ***namelist,
|
||||
int(*filter)(const struct dirent *),
|
||||
int(*compar)(const struct dirent **,
|
||||
const struct dirent **));
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _DIRENT_H_ */
|
||||
|
58
libc/include/features.h
Normal file
58
libc/include/features.h
Normal file
@ -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_ */
|
@ -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_ */
|
||||
|
@ -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
|
||||
|
@ -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()
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <endian.h>
|
||||
#include <linux/socket.h>
|
||||
#include <linux/in.h>
|
||||
#include <linux/in6.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
||||
/*
|
||||
|
@ -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_ */
|
||||
|
@ -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
|
||||
|
@ -29,6 +29,7 @@
|
||||
#define _SYS_ATOMICS_H
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
46
libc/include/sys/timeb.h
Normal file
46
libc/include/sys/timeb.h
Normal file
@ -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 */
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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.
|
||||
|
||||
yeah, right....
|
||||
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.
|
||||
|
||||
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)
|
||||
|
||||
|
31
libc/kernel/arch-x86/asm/a.out.h
Normal file
31
libc/kernel/arch-x86/asm/a.out.h
Normal file
@ -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
|
19
libc/kernel/arch-x86/asm/acpi.h
Normal file
19
libc/kernel/arch-x86/asm/acpi.h
Normal file
@ -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
|
15
libc/kernel/arch-x86/asm/acpi_32.h
Normal file
15
libc/kernel/arch-x86/asm/acpi_32.h
Normal file
@ -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
|
12
libc/kernel/arch-x86/asm/alternative.h
Normal file
12
libc/kernel/arch-x86/asm/alternative.h
Normal file
@ -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"
|
38
libc/kernel/arch-x86/asm/alternative_32.h
Normal file
38
libc/kernel/arch-x86/asm/alternative_32.h
Normal file
@ -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
|
12
libc/kernel/arch-x86/asm/apic.h
Normal file
12
libc/kernel/arch-x86/asm/apic.h
Normal file
@ -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"
|
31
libc/kernel/arch-x86/asm/apic_32.h
Normal file
31
libc/kernel/arch-x86/asm/apic_32.h
Normal file
@ -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
|
12
libc/kernel/arch-x86/asm/apicdef.h
Normal file
12
libc/kernel/arch-x86/asm/apicdef.h
Normal file
@ -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"
|
372
libc/kernel/arch-x86/asm/apicdef_32.h
Normal file
372
libc/kernel/arch-x86/asm/apicdef_32.h
Normal file
@ -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
|
12
libc/kernel/arch-x86/asm/atomic.h
Normal file
12
libc/kernel/arch-x86/asm/atomic.h
Normal file
@ -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"
|
39
libc/kernel/arch-x86/asm/atomic_32.h
Normal file
39
libc/kernel/arch-x86/asm/atomic_32.h
Normal file
@ -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
|
20
libc/kernel/arch-x86/asm/auxvec.h
Normal file
20
libc/kernel/arch-x86/asm/auxvec.h
Normal file
@ -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
|
12
libc/kernel/arch-x86/asm/bitops.h
Normal file
12
libc/kernel/arch-x86/asm/bitops.h
Normal file
@ -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"
|
30
libc/kernel/arch-x86/asm/bitops_32.h
Normal file
30
libc/kernel/arch-x86/asm/bitops_32.h
Normal file
@ -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
|
16
libc/kernel/arch-x86/asm/bug.h
Normal file
16
libc/kernel/arch-x86/asm/bug.h
Normal file
@ -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
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user