author | michaelm |
Tue, 06 Mar 2012 20:34:38 +0000 | |
changeset 12047 | 320a714614e9 |
parent 5506 | 202f599c92aa |
child 13536 | a372092b24ab |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
||
27 |
#include <stdlib.h> |
|
28 |
#include <string.h> |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
29 |
#ifdef MACOSX |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
30 |
#include <unistd.h> |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
31 |
#include <sys/param.h> |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
32 |
#endif |
2 | 33 |
#include <mlib_types.h> |
34 |
#include <mlib_sys_proto.h> |
|
35 |
#include "mlib_SysMath.h" |
|
36 |
||
37 |
/***************************************************************/ |
|
38 |
||
39 |
#if ! defined ( __MEDIALIB_OLD_NAMES ) |
|
40 |
#if defined ( __SUNPRO_C ) |
|
41 |
||
42 |
#pragma weak mlib_memmove = __mlib_memmove |
|
43 |
#pragma weak mlib_malloc = __mlib_malloc |
|
44 |
#pragma weak mlib_realloc = __mlib_realloc |
|
45 |
#pragma weak mlib_free = __mlib_free |
|
46 |
#pragma weak mlib_memset = __mlib_memset |
|
47 |
#pragma weak mlib_memcpy = __mlib_memcpy |
|
48 |
||
49 |
#ifdef MLIB_NO_LIBSUNMATH |
|
50 |
#pragma weak mlib_sincosf = __mlib_sincosf |
|
51 |
#endif /* MLIB_NO_LIBSUNMATH */ |
|
52 |
||
53 |
#elif defined ( __GNUC__ ) /* defined ( __SUNPRO_C ) */ |
|
54 |
||
55 |
__typeof__ ( __mlib_memmove) mlib_memmove |
|
56 |
__attribute__ ((weak,alias("__mlib_memmove"))); |
|
57 |
__typeof__ ( __mlib_malloc) mlib_malloc |
|
58 |
__attribute__ ((weak,alias("__mlib_malloc"))); |
|
59 |
__typeof__ ( __mlib_realloc) mlib_realloc |
|
60 |
__attribute__ ((weak,alias("__mlib_realloc"))); |
|
61 |
__typeof__ ( __mlib_free) mlib_free |
|
62 |
__attribute__ ((weak,alias("__mlib_free"))); |
|
63 |
__typeof__ ( __mlib_memset) mlib_memset |
|
64 |
__attribute__ ((weak,alias("__mlib_memset"))); |
|
65 |
__typeof__ ( __mlib_memcpy) mlib_memcpy |
|
66 |
__attribute__ ((weak,alias("__mlib_memcpy"))); |
|
67 |
||
68 |
#ifdef MLIB_NO_LIBSUNMATH |
|
69 |
||
70 |
void __mlib_sincosf (float x, float *s, float *c); |
|
71 |
||
72 |
__typeof__ ( __mlib_sincosf) mlib_sincosf |
|
73 |
__attribute__ ((weak,alias("__mlib_sincosf"))); |
|
74 |
#endif /* MLIB_NO_LIBSUNMATH */ |
|
75 |
||
76 |
#else /* defined ( __SUNPRO_C ) */ |
|
77 |
||
78 |
#error "unknown platform" |
|
79 |
||
80 |
#endif /* defined ( __SUNPRO_C ) */ |
|
81 |
#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ |
|
82 |
||
83 |
/***************************************************************/ |
|
84 |
||
85 |
void *__mlib_malloc(mlib_u32 size) |
|
86 |
{ |
|
87 |
#ifdef _MSC_VER |
|
88 |
/* |
|
89 |
* Currently, all MS C compilers for Win32 platforms default to 8 byte |
|
90 |
* alignment. -- from stdlib.h of MS VC++5.0. |
|
91 |
*/ |
|
92 |
return (void *) malloc(size); |
|
12047
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
93 |
#elif defined(MACOSX) |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
94 |
return valloc(size); |
320a714614e9
7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
5506
diff
changeset
|
95 |
#else |
2 | 96 |
return (void *) memalign(8, size); |
97 |
#endif /* _MSC_VER */ |
|
98 |
} |
|
99 |
||
100 |
void *__mlib_realloc(void *ptr, mlib_u32 size) |
|
101 |
{ |
|
102 |
return realloc(ptr, size); |
|
103 |
} |
|
104 |
||
105 |
void __mlib_free(void *ptr) |
|
106 |
{ |
|
107 |
free(ptr); |
|
108 |
} |
|
109 |
||
110 |
void *__mlib_memset(void *s, mlib_s32 c, mlib_u32 n) |
|
111 |
{ |
|
112 |
return memset(s, c, n); |
|
113 |
} |
|
114 |
||
115 |
void *__mlib_memcpy(void *s1, void *s2, mlib_u32 n) |
|
116 |
{ |
|
117 |
return memcpy(s1, s2, n); |
|
118 |
} |
|
119 |
||
120 |
void *__mlib_memmove(void *s1, void *s2, mlib_u32 n) |
|
121 |
{ |
|
122 |
return memmove(s1, s2, n); |
|
123 |
} |
|
124 |
||
125 |
#ifdef MLIB_NO_LIBSUNMATH |
|
126 |
||
127 |
void __mlib_sincosf (mlib_f32 x, mlib_f32 *s, mlib_f32 *c) |
|
128 |
{ |
|
129 |
*s = (mlib_f32)sin(x); |
|
130 |
*c = (mlib_f32)cos(x); |
|
131 |
} |
|
132 |
||
133 |
#endif /* MLIB_NO_LIBSUNMATH */ |