Path: blob/master/src/java.desktop/share/native/common/awt/medialib/mlib_sys.c
41161 views
/*1* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/242526#include <stdlib.h>27#include <string.h>28#ifdef MACOSX29#include <unistd.h>30#include <sys/param.h>31#else32#include <malloc.h>33#endif34#include <mlib_types.h>35#include <mlib_sys_proto.h>36#include "mlib_SysMath.h"3738/***************************************************************/3940#if ! defined ( __MEDIALIB_OLD_NAMES )41#if defined ( __GNUC__ )4243__typeof__ ( __mlib_memmove) mlib_memmove44__attribute__ ((weak,alias("__mlib_memmove")));45__typeof__ ( __mlib_malloc) mlib_malloc46__attribute__ ((weak,alias("__mlib_malloc")));47__typeof__ ( __mlib_realloc) mlib_realloc48__attribute__ ((weak,alias("__mlib_realloc")));49__typeof__ ( __mlib_free) mlib_free50__attribute__ ((weak,alias("__mlib_free")));51__typeof__ ( __mlib_memset) mlib_memset52__attribute__ ((weak,alias("__mlib_memset")));53__typeof__ ( __mlib_memcpy) mlib_memcpy54__attribute__ ((weak,alias("__mlib_memcpy")));5556void __mlib_sincosf (float x, float *s, float *c);5758__typeof__ ( __mlib_sincosf) mlib_sincosf59__attribute__ ((weak,alias("__mlib_sincosf")));6061#else /* defined ( __GNUC__ ) */6263#error "unknown platform"6465#endif /* defined ( __GNUC__ ) */66#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */6768/***************************************************************/6970void *__mlib_malloc(mlib_u32 size)71{72#if defined(_MSC_VER) || defined(AIX)73/*74* Currently, all MS C compilers for Win32 platforms default to 8 byte75* alignment. -- from stdlib.h of MS VC++5.0.76*77* On AIX, the malloc subroutine returns a pointer to space suitably78* aligned for the storage of any type of object (see 'man malloc').79*/80return (void *) malloc(size);81#elif defined(MACOSX)82return valloc(size);83#else84return (void *) memalign(8, size);85#endif /* _MSC_VER */86}8788void *__mlib_realloc(void *ptr, mlib_u32 size)89{90return realloc(ptr, size);91}9293void __mlib_free(void *ptr)94{95free(ptr);96}9798void *__mlib_memset(void *s, mlib_s32 c, mlib_u32 n)99{100return memset(s, c, n);101}102103void *__mlib_memcpy(void *s1, void *s2, mlib_u32 n)104{105return memcpy(s1, s2, n);106}107108void *__mlib_memmove(void *s1, void *s2, mlib_u32 n)109{110return memmove(s1, s2, n);111}112113void __mlib_sincosf (mlib_f32 x, mlib_f32 *s, mlib_f32 *c)114{115*s = (mlib_f32)sin(x);116*c = (mlib_f32)cos(x);117}118119120