0N/A/*
2362N/A * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A
0N/A#include <stdlib.h>
0N/A#include <string.h>
4632N/A#ifdef MACOSX
4632N/A#include <unistd.h>
4632N/A#include <sys/param.h>
4632N/A#endif
0N/A#include <mlib_types.h>
0N/A#include <mlib_sys_proto.h>
0N/A#include "mlib_SysMath.h"
0N/A
0N/A/***************************************************************/
0N/A
0N/A#if ! defined ( __MEDIALIB_OLD_NAMES )
0N/A#if defined ( __SUNPRO_C )
0N/A
0N/A#pragma weak mlib_memmove = __mlib_memmove
0N/A#pragma weak mlib_malloc = __mlib_malloc
0N/A#pragma weak mlib_realloc = __mlib_realloc
0N/A#pragma weak mlib_free = __mlib_free
0N/A#pragma weak mlib_memset = __mlib_memset
0N/A#pragma weak mlib_memcpy = __mlib_memcpy
0N/A
0N/A#ifdef MLIB_NO_LIBSUNMATH
0N/A#pragma weak mlib_sincosf = __mlib_sincosf
0N/A#endif /* MLIB_NO_LIBSUNMATH */
0N/A
0N/A#elif defined ( __GNUC__ ) /* defined ( __SUNPRO_C ) */
0N/A
0N/A __typeof__ ( __mlib_memmove) mlib_memmove
0N/A __attribute__ ((weak,alias("__mlib_memmove")));
0N/A __typeof__ ( __mlib_malloc) mlib_malloc
0N/A __attribute__ ((weak,alias("__mlib_malloc")));
0N/A __typeof__ ( __mlib_realloc) mlib_realloc
0N/A __attribute__ ((weak,alias("__mlib_realloc")));
0N/A __typeof__ ( __mlib_free) mlib_free
0N/A __attribute__ ((weak,alias("__mlib_free")));
0N/A __typeof__ ( __mlib_memset) mlib_memset
0N/A __attribute__ ((weak,alias("__mlib_memset")));
0N/A __typeof__ ( __mlib_memcpy) mlib_memcpy
0N/A __attribute__ ((weak,alias("__mlib_memcpy")));
0N/A
0N/A#ifdef MLIB_NO_LIBSUNMATH
0N/A
0N/Avoid __mlib_sincosf (float x, float *s, float *c);
0N/A
0N/A__typeof__ ( __mlib_sincosf) mlib_sincosf
0N/A __attribute__ ((weak,alias("__mlib_sincosf")));
0N/A#endif /* MLIB_NO_LIBSUNMATH */
0N/A
0N/A#else /* defined ( __SUNPRO_C ) */
0N/A
0N/A#error "unknown platform"
0N/A
0N/A#endif /* defined ( __SUNPRO_C ) */
0N/A#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
0N/A
0N/A/***************************************************************/
0N/A
0N/Avoid *__mlib_malloc(mlib_u32 size)
0N/A{
0N/A#ifdef _MSC_VER
0N/A /*
0N/A * Currently, all MS C compilers for Win32 platforms default to 8 byte
0N/A * alignment. -- from stdlib.h of MS VC++5.0.
0N/A */
0N/A return (void *) malloc(size);
4632N/A#elif defined(MACOSX)
4632N/A return valloc(size);
4632N/A#else
0N/A return (void *) memalign(8, size);
0N/A#endif /* _MSC_VER */
0N/A}
0N/A
0N/Avoid *__mlib_realloc(void *ptr, mlib_u32 size)
0N/A{
0N/A return realloc(ptr, size);
0N/A}
0N/A
0N/Avoid __mlib_free(void *ptr)
0N/A{
0N/A free(ptr);
0N/A}
0N/A
0N/Avoid *__mlib_memset(void *s, mlib_s32 c, mlib_u32 n)
0N/A{
0N/A return memset(s, c, n);
0N/A}
0N/A
0N/Avoid *__mlib_memcpy(void *s1, void *s2, mlib_u32 n)
0N/A{
0N/A return memcpy(s1, s2, n);
0N/A}
0N/A
0N/Avoid *__mlib_memmove(void *s1, void *s2, mlib_u32 n)
0N/A{
0N/A return memmove(s1, s2, n);
0N/A}
0N/A
0N/A#ifdef MLIB_NO_LIBSUNMATH
0N/A
0N/Avoid __mlib_sincosf (mlib_f32 x, mlib_f32 *s, mlib_f32 *c)
0N/A{
0N/A *s = (mlib_f32)sin(x);
0N/A *c = (mlib_f32)cos(x);
0N/A}
0N/A
0N/A#endif /* MLIB_NO_LIBSUNMATH */