1/*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz.
7 *
8 * Redistribution and use in source and binary forms, with or without
--- 24 unchanged lines hidden (view full) ---
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(SYSLIBC_SCCS) && !defined(lint)
38 .asciz "@(#)sbrk.s 5.1 (Berkeley) 4/23/90"
39#endif /* SYSLIBC_SCCS and not lint */
40#include <machine/asm.h>
41__FBSDID("$FreeBSD: head/lib/libc/amd64/sys/sbrk.S 115279 2003-05-24 17:35:23Z peter $");
42
43#include "SYS.h"
44
45 .globl CNAME(_end)
46 .globl HIDENAME(minbrk)
47 .globl HIDENAME(curbrk)
48
49 .data
50HIDENAME(minbrk): .quad CNAME(_end)
51HIDENAME(curbrk): .quad CNAME(_end)
52 .text
53
54ENTRY(sbrk)
55 pushq %rdi
56 movq %rdi,%rcx
57#ifdef PIC
58 movq PIC_GOT(HIDENAME(curbrk)),%rdx
59 movq (%rdx),%rax
60#else
61 movq HIDENAME(curbrk)(%rip),%rax
62#endif
63 testq %rcx,%rcx
64 jz back
65 addq %rax,%rdi
66 mov $SYS_break,%eax
67 KERNCALL
68 jb err
69#ifdef PIC
70 movq PIC_GOT(HIDENAME(curbrk)),%rdx
71 movq (%rdx),%rax
72#else
73 movq HIDENAME(curbrk)(%rip),%rax
74#endif
75 movq 0(%rsp), %rcx
76#ifdef PIC
77 addq %rcx,(%rdx)
78#else
79 addq %rcx,HIDENAME(curbrk)(%rip)
80#endif
81back:
82 addq $8, %rsp
83 ret
84err:
85 addq $8, %rsp
86#ifdef PIC
87 movq PIC_GOT(HIDENAME(cerror)),%rdx
88 jmp *%rdx
89#else
90 jmp HIDENAME(cerror)
91#endif
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz.
7 *
8 * Redistribution and use in source and binary forms, with or without
--- 24 unchanged lines hidden (view full) ---
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 */
36
37#if defined(SYSLIBC_SCCS) && !defined(lint)
38 .asciz "@(#)sbrk.s 5.1 (Berkeley) 4/23/90"
39#endif /* SYSLIBC_SCCS and not lint */
40#include <machine/asm.h>
41__FBSDID("$FreeBSD: head/lib/libc/amd64/sys/sbrk.S 115279 2003-05-24 17:35:23Z peter $");
42
43#include "SYS.h"
44
45 .globl CNAME(_end)
46 .globl HIDENAME(minbrk)
47 .globl HIDENAME(curbrk)
48
49 .data
50HIDENAME(minbrk): .quad CNAME(_end)
51HIDENAME(curbrk): .quad CNAME(_end)
52 .text
53
54ENTRY(sbrk)
55 pushq %rdi
56 movq %rdi,%rcx
57#ifdef PIC
58 movq PIC_GOT(HIDENAME(curbrk)),%rdx
59 movq (%rdx),%rax
60#else
61 movq HIDENAME(curbrk)(%rip),%rax
62#endif
63 testq %rcx,%rcx
64 jz back
65 addq %rax,%rdi
66 mov $SYS_break,%eax
67 KERNCALL
68 jb err
69#ifdef PIC
70 movq PIC_GOT(HIDENAME(curbrk)),%rdx
71 movq (%rdx),%rax
72#else
73 movq HIDENAME(curbrk)(%rip),%rax
74#endif
75 movq 0(%rsp), %rcx
76#ifdef PIC
77 addq %rcx,(%rdx)
78#else
79 addq %rcx,HIDENAME(curbrk)(%rip)
80#endif
81back:
82 addq $8, %rsp
83 ret
84err:
85 addq $8, %rsp
86#ifdef PIC
87 movq PIC_GOT(HIDENAME(cerror)),%rdx
88 jmp *%rdx
89#else
90 jmp HIDENAME(cerror)
91#endif