Support six-argument syscalls from C for 32-bit x86, use generic lowlevellock-futex...
[glibc.git] / sysdeps / unix / sysv / linux / i386 / sysdep.h
blob7f6fcf3288fb5b0b555ac642b43f2aeaf3a247b0
1 /* Copyright (C) 1992-2015 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper, <drepper@gnu.org>, August 1995.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #ifndef _LINUX_I386_SYSDEP_H
20 #define _LINUX_I386_SYSDEP_H 1
22 /* There is some commonality. */
23 #include <sysdeps/unix/i386/sysdep.h>
24 /* Defines RTLD_PRIVATE_ERRNO and USE_DL_SYSINFO. */
25 #include <dl-sysdep.h>
26 #include <tls.h>
29 /* For Linux we can use the system call table in the header file
30 /usr/include/asm/unistd.h
31 of the kernel. But these symbols do not follow the SYS_* syntax
32 so we have to redefine the `SYS_ify' macro here. */
33 #undef SYS_ify
34 #define SYS_ify(syscall_name) __NR_##syscall_name
36 #if defined USE_DL_SYSINFO \
37 && (IS_IN (libc) || IS_IN (libpthread))
38 # define I386_USE_SYSENTER 1
39 #else
40 # undef I386_USE_SYSENTER
41 #endif
43 #ifdef __ASSEMBLER__
45 /* Linux uses a negative return value to indicate syscall errors,
46 unlike most Unices, which use the condition codes' carry flag.
48 Since version 2.1 the return value of a system call might be
49 negative even if the call succeeded. E.g., the `lseek' system call
50 might return a large offset. Therefore we must not anymore test
51 for < 0, but test for a real error by making sure the value in %eax
52 is a real error number. Linus said he will make sure the no syscall
53 returns a value in -1 .. -4095 as a valid result so we can savely
54 test with -4095. */
56 /* We don't want the label for the error handle to be global when we define
57 it here. */
58 #ifdef PIC
59 # define SYSCALL_ERROR_LABEL 0f
60 #else
61 # define SYSCALL_ERROR_LABEL syscall_error
62 #endif
64 #undef PSEUDO
65 #define PSEUDO(name, syscall_name, args) \
66 .text; \
67 ENTRY (name) \
68 DO_CALL (syscall_name, args); \
69 cmpl $-4095, %eax; \
70 jae SYSCALL_ERROR_LABEL
72 #undef PSEUDO_END
73 #define PSEUDO_END(name) \
74 SYSCALL_ERROR_HANDLER \
75 END (name)
77 #undef PSEUDO_NOERRNO
78 #define PSEUDO_NOERRNO(name, syscall_name, args) \
79 .text; \
80 ENTRY (name) \
81 DO_CALL (syscall_name, args)
83 #undef PSEUDO_END_NOERRNO
84 #define PSEUDO_END_NOERRNO(name) \
85 END (name)
87 #define ret_NOERRNO ret
89 /* The function has to return the error code. */
90 #undef PSEUDO_ERRVAL
91 #define PSEUDO_ERRVAL(name, syscall_name, args) \
92 .text; \
93 ENTRY (name) \
94 DO_CALL (syscall_name, args); \
95 negl %eax
97 #undef PSEUDO_END_ERRVAL
98 #define PSEUDO_END_ERRVAL(name) \
99 END (name)
101 #define ret_ERRVAL ret
103 #ifndef PIC
104 # define SYSCALL_ERROR_HANDLER /* Nothing here; code in sysdep.S is used. */
105 #else
107 # if RTLD_PRIVATE_ERRNO
108 # define SYSCALL_ERROR_HANDLER \
109 0:SETUP_PIC_REG(cx); \
110 addl $_GLOBAL_OFFSET_TABLE_, %ecx; \
111 negl %eax; \
112 movl %eax, rtld_errno@GOTOFF(%ecx); \
113 orl $-1, %eax; \
114 ret;
116 # elif defined _LIBC_REENTRANT
118 # if IS_IN (libc)
119 # define SYSCALL_ERROR_ERRNO __libc_errno
120 # else
121 # define SYSCALL_ERROR_ERRNO errno
122 # endif
123 # define SYSCALL_ERROR_HANDLER \
124 0:SETUP_PIC_REG (cx); \
125 addl $_GLOBAL_OFFSET_TABLE_, %ecx; \
126 movl SYSCALL_ERROR_ERRNO@GOTNTPOFF(%ecx), %ecx; \
127 negl %eax; \
128 SYSCALL_ERROR_HANDLER_TLS_STORE (%eax, %ecx); \
129 orl $-1, %eax; \
130 ret;
131 # ifndef NO_TLS_DIRECT_SEG_REFS
132 # define SYSCALL_ERROR_HANDLER_TLS_STORE(src, destoff) \
133 movl src, %gs:(destoff)
134 # else
135 # define SYSCALL_ERROR_HANDLER_TLS_STORE(src, destoff) \
136 addl %gs:0, destoff; \
137 movl src, (destoff)
138 # endif
139 # else
140 /* Store (- %eax) into errno through the GOT. */
141 # define SYSCALL_ERROR_HANDLER \
142 0:SETUP_PIC_REG(cx); \
143 addl $_GLOBAL_OFFSET_TABLE_, %ecx; \
144 negl %eax; \
145 movl errno@GOT(%ecx), %ecx; \
146 movl %eax, (%ecx); \
147 orl $-1, %eax; \
148 ret;
149 # endif /* _LIBC_REENTRANT */
150 #endif /* PIC */
153 /* The original calling convention for system calls on Linux/i386 is
154 to use int $0x80. */
155 #ifdef I386_USE_SYSENTER
156 # ifdef SHARED
157 # define ENTER_KERNEL call *%gs:SYSINFO_OFFSET
158 # else
159 # define ENTER_KERNEL call *_dl_sysinfo
160 # endif
161 #else
162 # define ENTER_KERNEL int $0x80
163 #endif
165 /* Linux takes system call arguments in registers:
167 syscall number %eax call-clobbered
168 arg 1 %ebx call-saved
169 arg 2 %ecx call-clobbered
170 arg 3 %edx call-clobbered
171 arg 4 %esi call-saved
172 arg 5 %edi call-saved
173 arg 6 %ebp call-saved
175 The stack layout upon entering the function is:
177 24(%esp) Arg# 6
178 20(%esp) Arg# 5
179 16(%esp) Arg# 4
180 12(%esp) Arg# 3
181 8(%esp) Arg# 2
182 4(%esp) Arg# 1
183 (%esp) Return address
185 (Of course a function with say 3 arguments does not have entries for
186 arguments 4, 5, and 6.)
188 The following code tries hard to be optimal. A general assumption
189 (which is true according to the data books I have) is that
191 2 * xchg is more expensive than pushl + movl + popl
193 Beside this a neat trick is used. The calling conventions for Linux
194 tell that among the registers used for parameters %ecx and %edx need
195 not be saved. Beside this we may clobber this registers even when
196 they are not used for parameter passing.
198 As a result one can see below that we save the content of the %ebx
199 register in the %edx register when we have less than 3 arguments
200 (2 * movl is less expensive than pushl + popl).
202 Second unlike for the other registers we don't save the content of
203 %ecx and %edx when we have more than 1 and 2 registers resp.
205 The code below might look a bit long but we have to take care for
206 the pipelined processors (i586). Here the `pushl' and `popl'
207 instructions are marked as NP (not pairable) but the exception is
208 two consecutive of these instruction. This gives no penalty on
209 other processors though. */
211 #undef DO_CALL
212 #define DO_CALL(syscall_name, args) \
213 PUSHARGS_##args \
214 DOARGS_##args \
215 movl $SYS_ify (syscall_name), %eax; \
216 ENTER_KERNEL \
217 POPARGS_##args
219 #define PUSHARGS_0 /* No arguments to push. */
220 #define DOARGS_0 /* No arguments to frob. */
221 #define POPARGS_0 /* No arguments to pop. */
222 #define _PUSHARGS_0 /* No arguments to push. */
223 #define _DOARGS_0(n) /* No arguments to frob. */
224 #define _POPARGS_0 /* No arguments to pop. */
226 #define PUSHARGS_1 movl %ebx, %edx; L(SAVEBX1): PUSHARGS_0
227 #define DOARGS_1 _DOARGS_1 (4)
228 #define POPARGS_1 POPARGS_0; movl %edx, %ebx; L(RESTBX1):
229 #define _PUSHARGS_1 pushl %ebx; cfi_adjust_cfa_offset (4); \
230 cfi_rel_offset (ebx, 0); L(PUSHBX1): _PUSHARGS_0
231 #define _DOARGS_1(n) movl n(%esp), %ebx; _DOARGS_0(n-4)
232 #define _POPARGS_1 _POPARGS_0; popl %ebx; cfi_adjust_cfa_offset (-4); \
233 cfi_restore (ebx); L(POPBX1):
235 #define PUSHARGS_2 PUSHARGS_1
236 #define DOARGS_2 _DOARGS_2 (8)
237 #define POPARGS_2 POPARGS_1
238 #define _PUSHARGS_2 _PUSHARGS_1
239 #define _DOARGS_2(n) movl n(%esp), %ecx; _DOARGS_1 (n-4)
240 #define _POPARGS_2 _POPARGS_1
242 #define PUSHARGS_3 _PUSHARGS_2
243 #define DOARGS_3 _DOARGS_3 (16)
244 #define POPARGS_3 _POPARGS_3
245 #define _PUSHARGS_3 _PUSHARGS_2
246 #define _DOARGS_3(n) movl n(%esp), %edx; _DOARGS_2 (n-4)
247 #define _POPARGS_3 _POPARGS_2
249 #define PUSHARGS_4 _PUSHARGS_4
250 #define DOARGS_4 _DOARGS_4 (24)
251 #define POPARGS_4 _POPARGS_4
252 #define _PUSHARGS_4 pushl %esi; cfi_adjust_cfa_offset (4); \
253 cfi_rel_offset (esi, 0); L(PUSHSI1): _PUSHARGS_3
254 #define _DOARGS_4(n) movl n(%esp), %esi; _DOARGS_3 (n-4)
255 #define _POPARGS_4 _POPARGS_3; popl %esi; cfi_adjust_cfa_offset (-4); \
256 cfi_restore (esi); L(POPSI1):
258 #define PUSHARGS_5 _PUSHARGS_5
259 #define DOARGS_5 _DOARGS_5 (32)
260 #define POPARGS_5 _POPARGS_5
261 #define _PUSHARGS_5 pushl %edi; cfi_adjust_cfa_offset (4); \
262 cfi_rel_offset (edi, 0); L(PUSHDI1): _PUSHARGS_4
263 #define _DOARGS_5(n) movl n(%esp), %edi; _DOARGS_4 (n-4)
264 #define _POPARGS_5 _POPARGS_4; popl %edi; cfi_adjust_cfa_offset (-4); \
265 cfi_restore (edi); L(POPDI1):
267 #define PUSHARGS_6 _PUSHARGS_6
268 #define DOARGS_6 _DOARGS_6 (40)
269 #define POPARGS_6 _POPARGS_6
270 #define _PUSHARGS_6 pushl %ebp; cfi_adjust_cfa_offset (4); \
271 cfi_rel_offset (ebp, 0); L(PUSHBP1): _PUSHARGS_5
272 #define _DOARGS_6(n) movl n(%esp), %ebp; _DOARGS_5 (n-4)
273 #define _POPARGS_6 _POPARGS_5; popl %ebp; cfi_adjust_cfa_offset (-4); \
274 cfi_restore (ebp); L(POPBP1):
276 #else /* !__ASSEMBLER__ */
278 /* We need some help from the assembler to generate optimal code. We
279 define some macros here which later will be used. */
280 asm (".L__X'%ebx = 1\n\t"
281 ".L__X'%ecx = 2\n\t"
282 ".L__X'%edx = 2\n\t"
283 ".L__X'%eax = 3\n\t"
284 ".L__X'%esi = 3\n\t"
285 ".L__X'%edi = 3\n\t"
286 ".L__X'%ebp = 3\n\t"
287 ".L__X'%esp = 3\n\t"
288 ".macro bpushl name reg\n\t"
289 ".if 1 - \\name\n\t"
290 ".if 2 - \\name\n\t"
291 "error\n\t"
292 ".else\n\t"
293 "xchgl \\reg, %ebx\n\t"
294 ".endif\n\t"
295 ".endif\n\t"
296 ".endm\n\t"
297 ".macro bpopl name reg\n\t"
298 ".if 1 - \\name\n\t"
299 ".if 2 - \\name\n\t"
300 "error\n\t"
301 ".else\n\t"
302 "xchgl \\reg, %ebx\n\t"
303 ".endif\n\t"
304 ".endif\n\t"
305 ".endm\n\t");
307 /* Six-argument syscalls use an out-of-line helper, because an inline
308 asm using all registers apart from %esp cannot work reliably and
309 the assembler does not support describing an asm that saves and
310 restores %ebp itself as a separate stack frame. This structure
311 stores the arguments not passed in registers; %edi is passed with a
312 pointer to this structure. */
313 struct libc_do_syscall_args
315 int ebx, edi, ebp;
318 /* Define a macro which expands inline into the wrapper code for a system
319 call. */
320 #undef INLINE_SYSCALL
321 #define INLINE_SYSCALL(name, nr, args...) \
322 ({ \
323 unsigned int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
324 if (__glibc_unlikely (INTERNAL_SYSCALL_ERROR_P (resultvar, ))) \
326 __set_errno (INTERNAL_SYSCALL_ERRNO (resultvar, )); \
327 resultvar = 0xffffffff; \
329 (int) resultvar; })
331 /* Define a macro which expands inline into the wrapper code for a system
332 call. This use is for internal calls that do not need to handle errors
333 normally. It will never touch errno. This returns just what the kernel
334 gave back.
336 The _NCS variant allows non-constant syscall numbers but it is not
337 possible to use more than four parameters. */
338 #undef INTERNAL_SYSCALL
339 #define INTERNAL_SYSCALL_MAIN_0(name, err, args...) \
340 INTERNAL_SYSCALL_MAIN_INLINE(name, err, 0, args)
341 #define INTERNAL_SYSCALL_MAIN_1(name, err, args...) \
342 INTERNAL_SYSCALL_MAIN_INLINE(name, err, 1, args)
343 #define INTERNAL_SYSCALL_MAIN_2(name, err, args...) \
344 INTERNAL_SYSCALL_MAIN_INLINE(name, err, 2, args)
345 #define INTERNAL_SYSCALL_MAIN_3(name, err, args...) \
346 INTERNAL_SYSCALL_MAIN_INLINE(name, err, 3, args)
347 #define INTERNAL_SYSCALL_MAIN_4(name, err, args...) \
348 INTERNAL_SYSCALL_MAIN_INLINE(name, err, 4, args)
349 #define INTERNAL_SYSCALL_MAIN_5(name, err, args...) \
350 INTERNAL_SYSCALL_MAIN_INLINE(name, err, 5, args)
351 /* Each object using 6-argument inline syscalls must include a
352 definition of __libc_do_syscall. */
353 #define INTERNAL_SYSCALL_MAIN_6(name, err, arg1, arg2, arg3, \
354 arg4, arg5, arg6) \
355 struct libc_do_syscall_args _xv = \
357 (int) (arg1), \
358 (int) (arg5), \
359 (int) (arg6) \
360 }; \
361 asm volatile ( \
362 "movl %1, %%eax\n\t" \
363 "call __libc_do_syscall" \
364 : "=a" (resultvar) \
365 : "i" (__NR_##name), "c" (arg2), "d" (arg3), "S" (arg4), "D" (&_xv) \
366 : "memory", "cc")
367 #define INTERNAL_SYSCALL(name, err, nr, args...) \
368 ({ \
369 register unsigned int resultvar; \
370 INTERNAL_SYSCALL_MAIN_##nr (name, err, args); \
371 (int) resultvar; })
372 #ifdef I386_USE_SYSENTER
373 # ifdef SHARED
374 # define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
375 EXTRAVAR_##nr \
376 asm volatile ( \
377 LOADARGS_##nr \
378 "movl %1, %%eax\n\t" \
379 "call *%%gs:%P2\n\t" \
380 RESTOREARGS_##nr \
381 : "=a" (resultvar) \
382 : "i" (__NR_##name), "i" (offsetof (tcbhead_t, sysinfo)) \
383 ASMFMT_##nr(args) : "memory", "cc")
384 # define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
385 ({ \
386 register unsigned int resultvar; \
387 EXTRAVAR_##nr \
388 asm volatile ( \
389 LOADARGS_##nr \
390 "call *%%gs:%P2\n\t" \
391 RESTOREARGS_##nr \
392 : "=a" (resultvar) \
393 : "0" (name), "i" (offsetof (tcbhead_t, sysinfo)) \
394 ASMFMT_##nr(args) : "memory", "cc"); \
395 (int) resultvar; })
396 # else
397 # define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
398 EXTRAVAR_##nr \
399 asm volatile ( \
400 LOADARGS_##nr \
401 "movl %1, %%eax\n\t" \
402 "call *_dl_sysinfo\n\t" \
403 RESTOREARGS_##nr \
404 : "=a" (resultvar) \
405 : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc")
406 # define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
407 ({ \
408 register unsigned int resultvar; \
409 EXTRAVAR_##nr \
410 asm volatile ( \
411 LOADARGS_##nr \
412 "call *_dl_sysinfo\n\t" \
413 RESTOREARGS_##nr \
414 : "=a" (resultvar) \
415 : "0" (name) ASMFMT_##nr(args) : "memory", "cc"); \
416 (int) resultvar; })
417 # endif
418 #else
419 # define INTERNAL_SYSCALL_MAIN_INLINE(name, err, nr, args...) \
420 EXTRAVAR_##nr \
421 asm volatile ( \
422 LOADARGS_##nr \
423 "movl %1, %%eax\n\t" \
424 "int $0x80\n\t" \
425 RESTOREARGS_##nr \
426 : "=a" (resultvar) \
427 : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc")
428 # define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
429 ({ \
430 register unsigned int resultvar; \
431 EXTRAVAR_##nr \
432 asm volatile ( \
433 LOADARGS_##nr \
434 "int $0x80\n\t" \
435 RESTOREARGS_##nr \
436 : "=a" (resultvar) \
437 : "0" (name) ASMFMT_##nr(args) : "memory", "cc"); \
438 (int) resultvar; })
439 #endif
441 #undef INTERNAL_SYSCALL_DECL
442 #define INTERNAL_SYSCALL_DECL(err) do { } while (0)
444 #undef INTERNAL_SYSCALL_ERROR_P
445 #define INTERNAL_SYSCALL_ERROR_P(val, err) \
446 ((unsigned int) (val) >= 0xfffff001u)
448 #undef INTERNAL_SYSCALL_ERRNO
449 #define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
451 #define LOADARGS_0
452 #ifdef __PIC__
453 # if defined I386_USE_SYSENTER && defined SHARED
454 # define LOADARGS_1 \
455 "bpushl .L__X'%k3, %k3\n\t"
456 # define LOADARGS_5 \
457 "movl %%ebx, %4\n\t" \
458 "movl %3, %%ebx\n\t"
459 # else
460 # define LOADARGS_1 \
461 "bpushl .L__X'%k2, %k2\n\t"
462 # define LOADARGS_5 \
463 "movl %%ebx, %3\n\t" \
464 "movl %2, %%ebx\n\t"
465 # endif
466 # define LOADARGS_2 LOADARGS_1
467 # define LOADARGS_3 \
468 "xchgl %%ebx, %%edi\n\t"
469 # define LOADARGS_4 LOADARGS_3
470 #else
471 # define LOADARGS_1
472 # define LOADARGS_2
473 # define LOADARGS_3
474 # define LOADARGS_4
475 # define LOADARGS_5
476 #endif
478 #define RESTOREARGS_0
479 #ifdef __PIC__
480 # if defined I386_USE_SYSENTER && defined SHARED
481 # define RESTOREARGS_1 \
482 "bpopl .L__X'%k3, %k3\n\t"
483 # define RESTOREARGS_5 \
484 "movl %4, %%ebx"
485 # else
486 # define RESTOREARGS_1 \
487 "bpopl .L__X'%k2, %k2\n\t"
488 # define RESTOREARGS_5 \
489 "movl %3, %%ebx"
490 # endif
491 # define RESTOREARGS_2 RESTOREARGS_1
492 # define RESTOREARGS_3 \
493 "xchgl %%edi, %%ebx\n\t"
494 # define RESTOREARGS_4 RESTOREARGS_3
495 #else
496 # define RESTOREARGS_1
497 # define RESTOREARGS_2
498 # define RESTOREARGS_3
499 # define RESTOREARGS_4
500 # define RESTOREARGS_5
501 #endif
503 #define ASMFMT_0()
504 #ifdef __PIC__
505 # define ASMFMT_1(arg1) \
506 , "cd" (arg1)
507 # define ASMFMT_2(arg1, arg2) \
508 , "d" (arg1), "c" (arg2)
509 # define ASMFMT_3(arg1, arg2, arg3) \
510 , "D" (arg1), "c" (arg2), "d" (arg3)
511 # define ASMFMT_4(arg1, arg2, arg3, arg4) \
512 , "D" (arg1), "c" (arg2), "d" (arg3), "S" (arg4)
513 # define ASMFMT_5(arg1, arg2, arg3, arg4, arg5) \
514 , "0" (arg1), "m" (_xv), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5)
515 #else
516 # define ASMFMT_1(arg1) \
517 , "b" (arg1)
518 # define ASMFMT_2(arg1, arg2) \
519 , "b" (arg1), "c" (arg2)
520 # define ASMFMT_3(arg1, arg2, arg3) \
521 , "b" (arg1), "c" (arg2), "d" (arg3)
522 # define ASMFMT_4(arg1, arg2, arg3, arg4) \
523 , "b" (arg1), "c" (arg2), "d" (arg3), "S" (arg4)
524 # define ASMFMT_5(arg1, arg2, arg3, arg4, arg5) \
525 , "b" (arg1), "c" (arg2), "d" (arg3), "S" (arg4), "D" (arg5)
526 #endif
528 #define EXTRAVAR_0
529 #define EXTRAVAR_1
530 #define EXTRAVAR_2
531 #define EXTRAVAR_3
532 #define EXTRAVAR_4
533 #ifdef __PIC__
534 # define EXTRAVAR_5 int _xv;
535 #else
536 # define EXTRAVAR_5
537 #endif
539 /* Consistency check for position-independent code. */
540 #if defined __PIC__ && !__GNUC_PREREQ (5,0)
541 # define check_consistency() \
542 ({ int __res; \
543 __asm__ __volatile__ \
544 (LOAD_PIC_REG_STR (cx) ";" \
545 "subl %%ebx, %%ecx;" \
546 "je 1f;" \
547 "ud2;" \
548 "1:\n" \
549 : "=c" (__res)); \
550 __res; })
551 #endif
553 #endif /* __ASSEMBLER__ */
556 /* Pointer mangling support. */
557 #if IS_IN (rtld)
558 /* We cannot use the thread descriptor because in ld.so we use setjmp
559 earlier than the descriptor is initialized. Using a global variable
560 is too complicated here since we have no PC-relative addressing mode. */
561 #else
562 # ifdef __ASSEMBLER__
563 # define PTR_MANGLE(reg) xorl %gs:POINTER_GUARD, reg; \
564 roll $9, reg
565 # define PTR_DEMANGLE(reg) rorl $9, reg; \
566 xorl %gs:POINTER_GUARD, reg
567 # else
568 # define PTR_MANGLE(var) asm ("xorl %%gs:%c2, %0\n" \
569 "roll $9, %0" \
570 : "=r" (var) \
571 : "0" (var), \
572 "i" (offsetof (tcbhead_t, \
573 pointer_guard)))
574 # define PTR_DEMANGLE(var) asm ("rorl $9, %0\n" \
575 "xorl %%gs:%c2, %0" \
576 : "=r" (var) \
577 : "0" (var), \
578 "i" (offsetof (tcbhead_t, \
579 pointer_guard)))
580 # endif
581 #endif
583 #endif /* linux/i386/sysdep.h */