diff options
Diffstat (limited to 'sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386')
14 files changed, 920 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/Implies b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/Implies new file mode 100644 index 0000000000..772b20e20f --- /dev/null +++ b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/Implies @@ -0,0 +1 @@ +unix/sysv/solaris2/kopensolaris-gnu/x86 diff --git a/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/Makefile b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/Makefile new file mode 100644 index 0000000000..91bd35800a --- /dev/null +++ b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/Makefile @@ -0,0 +1,3 @@ +ifeq ($(subdir),stdlib) +gen-as-const-headers += ucontext_i.sym +endif diff --git a/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/__door_return.S b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/__door_return.S new file mode 100644 index 0000000000..0eb08da270 --- /dev/null +++ b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/__door_return.S @@ -0,0 +1,77 @@ +/* Copyright (C) 2008 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by David Bartley <dtbartle@csclub.uwaterloo.ca>, 2008. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <sysdep.h> +#include "door-offsets.h" + +/* The door_return call serves two purposes. First, it is called to transfer + the results of a door server back to the client. Second, it waits for a + client to pass in results destined for the server. The first part involves + no tricks; we simply call into the kernel. When the syscall returns, our + stack will have been adjusted; client args will have been copied onto the + stack. The stack pointer itself points to a struct door_results. + + For the second part, we need to pass the door results to the server + function. The first few fields of door_results matches the arguments of + the server function (probably by design) so we can just call the server + function. + + Since servers may block for any reason and to handle high-load doors, we + create a new server thread whenever there are none in the thread pool. */ + +ENTRY (__door_return) +L(restart): + DO_CALL (door, 6) + + /* Check for error. */ + jb SYSCALL_ERROR_LABEL; + + /* TODO: adjust cfi. */ + + /* Check nservers. */ + movl oDOOR_RESULTS_NSERVERS(%esp), %ecx + andl %ecx, %ecx + jg 1f + + /* Create another server thread. */ + movl oDOOR_RESULTS_DOOR_INFO(%esp), %ecx + pushl %ecx; cfi_adjust_cfa_offset (4); +#ifdef PIC + call __i686.get_pc_thunk.cx + addl $_GLOBAL_OFFSET_TABLE_, %ecx +#endif + +#ifdef PIC + movl door_server_create_proc@GOTOFF(%ecx), %ecx +#else + movl door_server_create_proc, %ecx +#endif + call *%ecx + addl $4, %esp; cfi_adjust_cfa_offset (-4); + +1: + /* Call server function. */ + movl oDOOR_RESULTS_PC(%esp), %ecx + call *%ecx + + /* The server function is supposed to call door_return... */ + pushl $0; cfi_adjust_cfa_offset (4); + call __pthread_exit +L(pseudo_end): +PSEUDO_END (__door_return) diff --git a/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/getcontext.S b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/getcontext.S new file mode 100644 index 0000000000..e989d3efb4 --- /dev/null +++ b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/getcontext.S @@ -0,0 +1,72 @@ +/* Copyright (C) 2008 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by David Bartley <dtbartle@csclub.uwaterloo.ca>, 2008. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <sysdep.h> + +#include "ucontext_i.h" + +/* note: make sure that we do not use %edx as a scratch (see swapcontext.S) */ + +ENTRY(__getcontext) + /* load ucp (arg) into %ecx */ + movl 4(%esp), %ecx + + /* load return address into %eax */ + movl 0(%esp), %eax + + /* push ucp, subcall number, and return address */ + pushl %ecx; cfi_adjust_cfa_offset (4) + pushl $SYS_SUB_getcontext; cfi_adjust_cfa_offset (4) + pushl %eax; cfi_adjust_cfa_offset (4) + + /* call context syscall */ + DO_CALL(context, 2) + + /* Jump if not error. */ + jnb 1f; + + /* pop args from stack */ + addl $12, %esp; cfi_adjust_cfa_offset (-12) + + /* Jump to error label. */ + jmp SYSCALL_ERROR_LABEL; + +1: + /* pop args from stack */ + addl $12, %esp; cfi_adjust_cfa_offset (-12); + + /* load ucp (arg) into %ecx */ + movl 4(%esp), %ecx + + /* save %esp */ + leal 4(%esp), %eax + movl %eax, oUESP(%ecx) + + /* save %eip */ + movl 0(%esp), %eax + movl %eax, oEIP(%ecx) + + /* return 0 on success */ + xorl %eax, %eax + movl %eax, oEAX(%ecx) +L(pseudo_end): + ret +PSEUDO_END(__getcontext) + +weak_alias (__getcontext, getcontext) diff --git a/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/lsee64.S b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/lsee64.S new file mode 100644 index 0000000000..b23cdc7671 --- /dev/null +++ b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/lsee64.S @@ -0,0 +1,38 @@ +/* Copyright (C) 2008 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by David Bartley <dtbartle@csclub.uwaterloo.ca>, 2008. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <sysdep.h> + +ENTRY (__libc_lseek64) + DO_CALL (llseek, 3) + jnb 1f + ret +1: + jmp SYSCALL_ERROR_LABEL + +L(pseudo_end): + + /* set the upper-64 bits to -1 */ + orl $-1, %edx; + ret +PSEUDO_END (__libc_lseek64) + +libc_hidden_def (__libc_lseek64) +weak_alias (__libc_lseek64, __lseek64) +weak_alias (__libc_lseek64, lseek64) diff --git a/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/makecontext.c b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/makecontext.c new file mode 100644 index 0000000000..2fcdb8f0d6 --- /dev/null +++ b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/makecontext.c @@ -0,0 +1,50 @@ +/* Copyright (C) 2008 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by David Bartley <dtbartle@csclub.uwaterloo.ca>, 2008. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <sys/types.h> +#include <sys/regset.h> +#include <sys/stack.h> +#include <ucontext.h> +#include <stdarg.h> +#include <assert.h> + +void +__restorecontext (void) +{ + ucontext_t uc; + assert (getcontext (&uc) == 0); + assert (setcontext (uc.uc_link) == 0); +} + +void +makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...) +{ + /* setup the stack (note that it grows down) */ + void *stack_addr = ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size - + (argc + 1) * sizeof(uint32_t); + uint32_t *stack_ptr = (uint32_t *)((uint32_t)stack_addr & + ~(STACK_ALIGN - 1)); + ucp->uc_mcontext.gregs[UESP] = (greg_t)stack_ptr; + *stack_ptr++ = (uint32_t)__restorecontext; /* return addr */ + va_list ap; + va_start (ap, argc); + while (argc--) + *stack_ptr++ = (uint32_t)va_arg (ap, char *); /* arg */ + ucp->uc_mcontext.gregs[EIP] = (greg_t)func; +} diff --git a/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/profil-counter.h b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/profil-counter.h new file mode 100644 index 0000000000..8091fbce14 --- /dev/null +++ b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/profil-counter.h @@ -0,0 +1,27 @@ +/* Machine-dependent SIGPROF signal handler. OpenSolaris i386 version. + Copyright (C) 1996, 1997, 2008 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <sys/ucontext.h> +#include <sys/regset.h> + +static void +profil_counter (int signr, int code, struct ucontext *ucp) +{ + profil_count ((void *) ucp->uc_mcontext.gregs[EIP]); +} diff --git a/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/swapcontext.S b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/swapcontext.S new file mode 100644 index 0000000000..a7b9fe1b02 --- /dev/null +++ b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/swapcontext.S @@ -0,0 +1,86 @@ +/* Copyright (C) 2008 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by David Bartley <dtbartle@csclub.uwaterloo.ca>, 2008. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <sysdep.h> + +#include <ucontext_i.h> + +ENTRY(__swapcontext) + + /* load ucp (arg) into %ecx */ + movl 4(%esp), %ecx + + /* load return address into %eax */ + movl 0(%esp), %eax + + /* push ucp, subcall number, and return address */ + pushl %ecx; cfi_adjust_cfa_offset (4) + pushl $SYS_SUB_getcontext; cfi_adjust_cfa_offset (4) + pushl %eax; cfi_adjust_cfa_offset (4) + + /* call context syscall */ + DO_CALL(context, 2) + + /* Jump if not error. */ + jnb 1f; + + /* pop args from stack */ + addl $12, %esp; cfi_adjust_cfa_offset (-12); + + /* Jump to error label. */ + jmp SYSCALL_ERROR_LABEL; + +1: + /* pop args from stack */ + addl $12, %esp; cfi_adjust_cfa_offset (-12); + + /* load ucp (arg) into %ecx */ + movl 4(%esp), %ecx + + /* save %esp */ + leal 4(%esp), %eax + movl %eax, oUESP(%ecx) + + /* save %eip */ + movl 0(%esp), %eax + movl %eax, oEIP(%ecx) + + /* return 0 on success */ + xorl %eax, %eax + movl %eax, oEAX(%ecx) + + /* load ocp (arg 2) into %edx */ + movl 8(%esp), %edx + + /* push ucp */ + pushl %edx; cfi_adjust_cfa_offset (4); + + /* call __setcontext */ + call __setcontext + + /* pop ucp */ + addl $4, %esp; cfi_adjust_cfa_offset (-4) + + /* __setcontext sets the return (%eax) */ +L(pseudo_end): + ret + +PSEUDO_END(__swapcontext) + +weak_alias (__swapcontext, swapcontext) diff --git a/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/sys/trap.h b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/sys/trap.h new file mode 100644 index 0000000000..b455c86368 --- /dev/null +++ b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/sys/trap.h @@ -0,0 +1,61 @@ +/* Declaration of traps. + Copyright (C) 2008 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _SYS_TRAP_H +#define _SYS_TRAP_H + +/* traps */ +#define T_ZERODIV 0x0 +#define T_SGLSTP 0x1 +#define T_NMIFLT 0x2 +#define T_BPTFLT 0x3 +#define T_OVFLW 0x4 +#define T_BOUNDFLT 0x5 +#define T_ILLINST 0x6 +#define T_NOEXTFLT 0x7 +#define T_DBLFLT 0x8 +#define T_EXTOVRFLT 0x9 +#define T_TSSFLT 0xa +#define T_SEGFLT 0xb +#define T_STKFLT 0xc +#define T_GPFLT 0xd +#define T_PGFLT 0xe +#define T_EXTERRFLT 0x10 +#define T_ALIGNMENT 0x11 +#define T_MCE 0x12 +#define T_SIMDFPE 0x13 +#define T_DBGENTR 0x14 +#define T_ENDPERR 0x21 +#define T_ENOEXTFLT 0x20 +#define T_FASTTRAP 0xd2 +#define T_SYSCALLINT 0x91 +#define T_DTRACE_RET 0x7f +#define T_INT80 0x80 +#define T_SOFTINT 0x50fd + +/* fast traps */ +#define T_FNULL 0 +#define T_FGETFP 1 +#define T_FSETFP 2 +#define T_GETHRTIME 3 +#define T_GETHRVTIME 4 +#define T_GETHRESTIME 5 +#define T_GETLGRP 6 + +#endif /* _SYS_TRAP_H */ diff --git a/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/syscall.S b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/syscall.S new file mode 100644 index 0000000000..3228730758 --- /dev/null +++ b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/syscall.S @@ -0,0 +1,51 @@ +/* Copyright (C) 1993, 1995-1998, 2002, 2008 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <sysdep.h> + + .text; +ENTRY (__syscall) + popl %ecx /* Pop return address into %ecx. */ + popl %eax /* Pop syscall number into %eax. */ + pushl %ecx /* Push back return adderss. */ + int $0x91 /* Do the system call. */ + pushl %ecx /* Push back return address. */ + jb SYSCALL_ERROR_LABEL; /* Jump to error handler if error. */ + +L(pseudo_end): + ret /* Return to caller. */ +PSEUDO_END (__syscall) +weak_alias (__syscall, syscall) + + .text; +ENTRY (__systemcall) + popl %edx /* Pop return address into %edx. */ + popl %ecx /* Pop sysret_t into %ecx. */ + popl %eax /* Pop syscall number into %eax. */ + pushl %edx /* Push return address onto stack. */ + int $0x91 /* Do the system call. */ + pushl %ecx /* Restore sysret_t on stack. */ + movl 4(%esp), %edx /* Save return address into %edx. */ + pushl %edx /* Restore return address on stack. */ + jb 1f /* Jump to error handler if error. */ + movl %eax, 0(%ecx) /* Set first 4 bytes of sysret_t. */ + movl %edx, 4(%ecx) /* Set second 4 bytes of sysret_t. */ + xorl %eax, %eax /* Set return to 0. */ +1: + ret +PSEUDO_END (__syscall) diff --git a/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/sysdep.S b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/sysdep.S new file mode 100644 index 0000000000..68c63878a0 --- /dev/null +++ b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/sysdep.S @@ -0,0 +1,40 @@ +/* Copyright (C) 1995-1998, 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <sysdep.h> +#define _ERRNO_H +#include <bits/errno.h> + +/* The following code is only used in the shared library when we + compile the reentrant version. Otherwise each system call defines + its own version. */ + +#ifndef PIC + +/* The syscall stubs jump here when they detect an error. + The code for Solaris is identical to the canonical Unix/i386 code. */ + +#undef CALL_MCOUNT +#define CALL_MCOUNT /* Don't insert the profiling call, it clobbers %eax. */ + + .text +ENTRY (__syscall_error) +#define __syscall_error __syscall_error_1 +#include <sysdeps/unix/i386/sysdep.S> + +#endif /* !PIC */ diff --git a/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/sysdep.h b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/sysdep.h new file mode 100644 index 0000000000..f93fdba57e --- /dev/null +++ b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/sysdep.h @@ -0,0 +1,324 @@ +/* Copyright (C) 1992,1993,1995-2000,2002-2006,2007,2008 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper, <drepper@gnu.org>, August 1995. + OpenSolaris bits contributed by David Bartley + <dtbartle@csclub.uwaterloo.ca>, 2008. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#ifndef _OPENSOLARIS_I386_SYSDEP_H +#define _OPENSOLARIS_I386_SYSDEP_H 1 + +#define DECLARE_INLINE_SYSCALL(ret, name, args...) \ + extern ret __syscall_##name (args) + +/* There is some commonality. */ +#include <sysdeps/unix/i386/sysdep.h> +#include <bp-sym.h> +#include <bp-asm.h> +#include <syscallP.h> + +/* XXX: This needs to come before #include <tls.h>. */ + +/* Pointer mangling support. */ +#if defined NOT_IN_libc && defined IS_IN_rtld +/* We cannot use the thread descriptor because in ld.so we use setjmp + earlier than the descriptor is initialized. Using a global variable + is too complicated here since we have no PC-relative addressing mode. */ +#else +# ifdef __ASSEMBLER__ +# define PTR_MANGLE(reg) xorl %gs:POINTER_GUARD, reg; \ + roll $9, reg +# define PTR_DEMANGLE(reg) rorl $9, reg; \ + xorl %gs:POINTER_GUARD, reg +# else +# define PTR_MANGLE(var) asm ("xorl %%gs:%c2, %0\n" \ + "roll $9, %0" \ + : "=r" (var) \ + : "0" (var), \ + "i" (offsetof (tcbhead_t, \ + pointer_guard))) +# define PTR_DEMANGLE(var) asm ("rorl $9, %0\n" \ + "xorl %%gs:%c2, %0" \ + : "=r" (var) \ + : "0" (var), \ + "i" (offsetof (tcbhead_t, \ + pointer_guard))) +# endif +#endif + + +/* Defines RTLD_PRIVATE_ERRNO and USE_DL_SYSINFO. */ +#include <dl-sysdep.h> +#include <tls.h> + +/* It's too much trouble to pull in all of errno.h just for this */ +#ifndef ERESTART +# define ERESTART 91 /* Restartable system call. */ +# define EINTR 4 /* Interrupted system call. */ +#endif + +#ifdef __ASSEMBLER__ + +/* This is needed so that we know when to set %edx to -1 on error. */ +#ifdef SYSCALL_64BIT_RETURN +# define SYSCALL_64BIT_RETURN_ASM orl $-1, %edx; +#else +# define SYSCALL_64BIT_RETURN_ASM +#endif + +#ifdef SYSCALL_RESTARTABLE +# define DO_RESTART \ + cmpl $ERESTART, %eax; \ + je L(restart); +#else +# define DO_RESTART +#endif + +/* We don't want the label for the error handle to be global when we define + it here. */ +#ifdef PIC +# define SYSCALL_ERROR_LABEL 0f +#else +# define SYSCALL_ERROR_LABEL syscall_error +#endif + +#undef PSEUDO +#define PSEUDO(name, syscall_name, args) \ + .text; \ + ENTRY (name) \ + L(restart): \ + DO_CALL (syscall_name, args); \ + jnb 2f; \ + DO_RESTART \ + jmp SYSCALL_ERROR_LABEL; \ +2: \ + L(pseudo_end): + +#define PSEUDO_SUBCALL(name, syscall_name, subcall_name, args) \ + .text; \ + ENTRY (name) \ + movl 0(%esp), %ecx; \ + movl %ecx, -4(%esp); \ + addl $-4, %esp; \ + movl $SYS_ify (SUB_##subcall_name), 4(%esp); \ + L(restart): \ + DO_CALL (syscall_name, args); \ + jnb 2f; \ + DO_RESTART \ + movl %ecx, 4(%esp); \ + addl $4, %esp; \ + jmp SYSCALL_ERROR_LABEL; \ +2: \ + movl %ecx, 4(%esp); \ + addl $4, %esp; \ + L(pseudo_end): + +#undef PSEUDO_END +#define PSEUDO_END(name) \ + SYSCALL_ERROR_HANDLER \ + END (name) + +#undef PSEUDO_NOERRNO +#define PSEUDO_NOERRNO(name, syscall_name, args) \ + .text; \ + ENTRY (name) \ + DO_CALL (syscall_name, args) + +#define PSEUDO_SUBCALL_NOERRNO(name, syscall_name, subcall_name, args) \ + .text; \ + ENTRY (name) \ + movl 0(%esp), %ecx; \ + movl %ecx, -4(%esp); \ + addl $-4, %esp; \ + movl $SYS_ify (SUB_##subcall_name), 4(%esp); \ + DO_CALL (syscall_name, args); \ + movl %ecx, 4(%esp); \ + addl $4, %esp; + +#undef PSEUDO_END_NOERRNO +#define PSEUDO_END_NOERRNO(name) \ + END (name) + +#define ret_NOERRNO ret + +/* The function has to return the error code. */ +#undef PSEUDO_ERRVAL +#define PSEUDO_ERRVAL(name, syscall_name, args) \ + .text; \ + ENTRY (name) \ + DO_CALL (syscall_name, args); \ + jnb 1f; \ + cmpl $ERESTART, %eax; \ + jne 2f; \ + movl $EINTR, %eax; \ + jmp 2f; \ +1: xorl %eax, %eax; \ +2:; + +#define PSEUDO_SUBCALL_ERRVAL(name, syscall_name, subcall_name, args) \ + .text; \ + ENTRY (name) \ + movl 0(%esp), %ecx; \ + movl %ecx, -4(%esp); \ + addl $-4, %esp; \ + movl $SYS_ify (SUB_##subcall_name), 4(%esp); \ + L(restart): \ + DO_CALL (syscall_name, args); \ + jnb 1f; \ + cmpl $ERESTART, %eax; \ + jne 2f; \ + movl $EINTR, %eax; \ + jmp 2f; \ +1: xorl %eax, %eax; \ +2: \ + movl %ecx, 4(%esp); \ + addl $4, %esp; + + +#undef PSEUDO_END_ERRVAL +#define PSEUDO_END_ERRVAL(name) \ + END (name) + +#define ret_ERRVAL ret + +#undef PSEUDO_FASTTRAP +#define PSEUDO_FASTTRAP(name, trap_name, args) \ + .text; \ + ENTRY (name) \ + movl $T_##trap_name, %eax; \ + int $T_FASTTRAP; \ + L(pseudo_end): + + +#ifndef PIC +# define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */ +#else + +# if RTLD_PRIVATE_ERRNO +# define SYSCALL_ERROR_HANDLER \ +0: SETUP_PIC_REG(cx); \ + addl $_GLOBAL_OFFSET_TABLE_, %ecx; \ + movl %eax, rtld_errno@GOTOFF(%ecx); \ + orl $-1, %eax; \ + SYSCALL_64BIT_RETURN_ASM \ + jmp L(pseudo_end); + +# elif defined _LIBC_REENTRANT + +# if USE___THREAD +# ifndef NOT_IN_libc +# define SYSCALL_ERROR_ERRNO __libc_errno +# else +# define SYSCALL_ERROR_ERRNO errno +# endif +# define SYSCALL_ERROR_HANDLER \ +0: SETUP_PIC_REG (cx); \ + addl $_GLOBAL_OFFSET_TABLE_, %ecx; \ + movl SYSCALL_ERROR_ERRNO@GOTNTPOFF(%ecx), %ecx; \ + SYSCALL_ERROR_HANDLER_TLS_STORE (%eax, %ecx); \ + orl $-1, %eax; \ + SYSCALL_64BIT_RETURN_ASM \ + jmp L(pseudo_end); +# ifndef NO_TLS_DIRECT_SEG_REFS +# define SYSCALL_ERROR_HANDLER_TLS_STORE(src, destoff) \ + movl src, %gs:(destoff) +# else +# define SYSCALL_ERROR_HANDLER_TLS_STORE(src, destoff) \ + addl %gs:0, destoff; \ + movl src, (destoff) +# endif +# else +# define SYSCALL_ERROR_HANDLER \ +0:pushl %ebx; \ + cfi_adjust_cfa_offset (4); \ + cfi_rel_offset (ebx, 0); \ + SETUP_PIC_REG (bx); \ + addl $_GLOBAL_OFFSET_TABLE_, %ebx; \ + pushl %eax; \ + cfi_adjust_cfa_offset (4); \ + PUSH_ERRNO_LOCATION_RETURN; \ + call BP_SYM (__errno_location)@PLT; \ + POP_ERRNO_LOCATION_RETURN; \ + popl %ecx; \ + cfi_adjust_cfa_offset (-4); \ + popl %ebx; \ + cfi_adjust_cfa_offset (-4); \ + cfi_restore (ebx); \ + movl %ecx, (%eax); \ + orl $-1, %eax; \ + SYSCALL_64BIT_RETURN_ASM \ + jmp L(pseudo_end); +/* A quick note: it is assumed that the call to `__errno_location' does + not modify the stack! */ +# endif +# else +/* Store (%eax) into errno through the GOT. */ +# define SYSCALL_ERROR_HANDLER \ +0:SETUP_PIC_REG(cx); \ + addl $_GLOBAL_OFFSET_TABLE_, %ecx; \ + movl errno@GOT(%ecx), %ecx; \ + movl %eax, (%ecx); \ + orl $-1, %eax; \ + SYSCALL_64BIT_RETURN_ASM \ + jmp L(pseudo_end); +# endif /* _LIBC_REENTRANT */ +#endif /* PIC */ + +/* TODO: use sysenter instead of int */ +#undef DO_CALL +#define DO_CALL(syscall_name, args) \ + movl $SYS_ify (syscall_name), %eax; \ + int $0x91 + +#else /* !__ASSEMBLER__ */ + +/* Consistency check for position-independent code. */ +#ifdef __PIC__ +# define check_consistency() \ + ({ int __res; \ + __asm__ __volatile__ \ + ("call __i686.get_pc_thunk.cx;" \ + "addl $_GLOBAL_OFFSET_TABLE_, %%ecx;" \ + "subl %%ebx, %%ecx;" \ + "je 1f;" \ + "ud2;" \ + "1:\n" \ + ".section .gnu.linkonce.t.__i686.get_pc_thunk.cx,\"ax\",@progbits;" \ + ".globl __i686.get_pc_thunk.cx;" \ + ".hidden __i686.get_pc_thunk.cx;" \ + ".type __i686.get_pc_thunk.cx,@function;" \ + "__i686.get_pc_thunk.cx:" \ + "movl (%%esp), %%ecx;" \ + "ret;" \ + ".previous" \ + : "=c" (__res)); \ + __res; }) +#endif + +/* TODO: This is a terrible implementation of INTERNAL_SYSCALL. */ + +/* Some NPTL code calls these macros. */ +# include <errno.h> +# define INTERNAL_SYSCALL(name, err, nr, args...) __internal_##name##_##nr (&(err), args) +# define INTERNAL_SYSCALL_DECL(err) int err = 0; +# define INTERNAL_SYSCALL_ERROR_P(val, err) (err != 0) +# define INTERNAL_SYSCALL_ERRNO(val, err) (err) + +#endif /* __ASSEMBLER__ */ + +#endif /* _OPENSOLARIS_I386_SYSDEP_H */ diff --git a/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/ucontext_i.sym b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/ucontext_i.sym new file mode 100644 index 0000000000..d57e0254e6 --- /dev/null +++ b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/ucontext_i.sym @@ -0,0 +1,31 @@ +#include <stddef.h> +#include <signal.h> +#include <sys/ucontext.h> +#include <sys/regset.h> + +-- + +SIG_BLOCK +SIG_SETMASK + +#define ucontext(member) offsetof (ucontext_t, member) +#define mcontext(member) ucontext (uc_mcontext.member) +#define mreg(reg) mcontext (gregs[reg]) + +oLINK ucontext (uc_link) +oSS_SP ucontext (uc_stack.ss_sp) +oSS_SIZE ucontext (uc_stack.ss_size) +oGS mreg (GS) +oFS mreg (FS) +oEDI mreg (EDI) +oESI mreg (ESI) +oEBP mreg (EBP) +oESP mreg (ESP) +oUESP mreg (UESP) +oEBX mreg (EBX) +oEDX mreg (EDX) +oECX mreg (ECX) +oEAX mreg (EAX) +oEIP mreg (EIP) +oFPREGS mcontext (fpregs) +oSIGMASK ucontext (uc_sigmask) diff --git a/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/vfork.S b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/vfork.S new file mode 100644 index 0000000000..08e02a969e --- /dev/null +++ b/sysdeps/unix/sysv/solaris2/kopensolaris-gnu/i386/vfork.S @@ -0,0 +1,59 @@ +/* Copyright (C) 2008 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by David Bartley <dtbartle@csclub.uwaterloo.ca>, 2008. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include <sysdep.h> + +ENTRY (__vfork) + + /* save the return address */ + popl %ecx; cfi_adjust_cfa_offset (-4) + + /* call vforkx(0) */ + pushl $0; cfi_adjust_cfa_offset (4) + pushl $SYS_SUB_vforkx; cfi_adjust_cfa_offset (4) + pushl %ecx; cfi_adjust_cfa_offset (4) + DO_CALL (forksys, 1) + jb 2f + + /* pop vforkx args */ + addl $12, %esp; cfi_adjust_cfa_offset (-12) + + /* In the parent process, %edx == 0, %eax == child pid. + In the child process, %edx == 1, %eax == parent pid. */ + decl %edx + andl %edx, %eax + + /* jump to the old return address */ + jmp *%ecx + +2: + /* pop vforkx args */ + addl $12, %esp; cfi_adjust_cfa_offset (-12) + + /* restore the return address and jump to the syscall error label */ + pushl %ecx; cfi_adjust_cfa_offset (4) + jmp SYSCALL_ERROR_LABEL + +L(pseudo_end): + ret + +PSEUDO_END (__vfork) + +libc_hidden_def (__vfork) +weak_alias (__vfork, vfork) |
