Chameleon

Chameleon Svn Source Tree

Root/branches/cparm/i386/libsa/sbrk.c

1/*
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25/*
26 *File:sbrk.c
27 *
28 *Unix compatibility for sbrk system call.
29 *
30 * HISTORY
31 * 09-Mar-90 Gregg Kellogg (gk) at NeXT.
32 *include <kern/mach_interface.h> instead of <kern/mach.h>
33 *
34 * 14-Feb-89 Avadis Tevanian (avie) at NeXT.
35 *Total rewrite using a fixed area of VM from break region.
36 */
37
38#include "libsa.h"
39#include "memory.h"
40
41/*
42 * natural_t and integer_t are Mach's legacy types for machine-
43 * independent integer types (unsigned, and signed, respectively).
44 * Their original purpose was to define other types in a machine/
45 * compiler independent way.
46 *
47 * They also had an implicit "same size as pointer" characteristic
48 * to them (i.e. Mach's traditional types are very ILP32 or ILP64
49 * centric). We support x86 ABIs that do not follow either of
50 * these models (specifically LP64). Therefore, we had to make a
51 * choice between making these types scale with pointers or stay
52 * tied to integers. Because their use is predominantly tied to
53 * to the size of an integer, we are keeping that association and
54 * breaking free from pointer size guarantees.
55 *
56 * New use of these types is discouraged.
57 */
58typedef __darwin_natural_tnatural_t;
59
60/*
61 * A vm_offset_t is a type-neutral pointer,
62 * e.g. an offset into a virtual memory space.
63 */
64#ifdef __LP64__
65typedef uintptr_tvm_offset_t;
66#else/* __LP64__ */
67typedefnatural_tvm_offset_t;
68#endif/* __LP64__ */
69
70/*
71 * A vm_size_t is the proper type for e.g.
72 * expressing the difference between two
73 * vm_offset_t entities.
74 */
75#ifdef __LP64__
76typedef uintptr_tvm_size_t;
77#else/* __LP64__ */
78typedefnatural_tvm_size_t;
79#endif/* __LP64__ */
80
81typedef vm_offset_t vm_address_t;
82
83static vm_size_t sbrk_region_size = (vm_size_t)MALLOC_LEN; /* Well, what should it be? */
84static vm_address_t sbrk_curbrk = (vm_address_t)MALLOC_ADDR;
85
86caddr_t sbrk(size)
87intsize;
88{
89if (size <= 0)
90return((caddr_t)sbrk_curbrk);
91
92 if (size > sbrk_region_size)
93 return((caddr_t)-1);
94
95sbrk_curbrk += size;
96sbrk_region_size -= size;
97
98return((caddr_t)(sbrk_curbrk - size));
99}
100
101caddr_t brk(x)
102caddr_t x;
103{
104return((caddr_t)-1);
105}
106

Archive Download this file

Revision: HEAD