jdk/src/share/native/sun/awt/medialib/mlib_sys.c
author michaelm
Tue, 06 Mar 2012 20:34:38 +0000
changeset 12047 320a714614e9
parent 5506 202f599c92aa
child 13536 a372092b24ab
permissions -rw-r--r--
7113349: Initial changeset for Macosx port to jdk Reviewed-by: jjh, alanb, dholmes, anthony, ohrstrom, ksrini, jrose, weijun, smarks Contributed-by: Alan Bateman <alan.bateman@oracle.com>, Alexander Potochkin <alexander.potochkin@oracle.com>, Alexander Zuev <alexander.zuev@oracle.com>, Andrew Brygin <andrew.brygin@oracle.com>, Artem Ananiev <artem.ananiev@oracle.com>, Alex Strange <astrange@apple.com>, Bino George <bino@apple.com>, Christine Lu <christine.lu@oracle.com>, David Katleman <david.katleman@oracle.com>, David Durrence <david_durrence@apple.com>, Dmitry Cherepanov <dmitry.cherepanov@oracle.com>, Greg Lewis <glewis@eyesbeyond.com>, Kevin Miller <kevin_m_miller@apple.com>, Kurt Miller <kurt@intricatesoftware.com>, Landon Fuller <landonf@plausiblelabs.com>, Leonid Romanov <leonid.romanov@oracle.com>, Loefty Walkowiak <loefty@apple.com>, Mark Reinhold <mark.reinhold@oracle.com>, Naoto Sato <naoto.sato@oracle.com>, Philip Race <philip.race@oracle.com>, Roger Hoover <rhoover@apple.com>, Scott Kovatch <scott.kovatch@oracle.com>, Sergey ByloKhov <sergey.bylokhov@oracle.com>, Mike Swingler <swingler@apple.com>, Tomas Hurka <tomas.hurka@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include <stdlib.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include <mlib_types.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include <mlib_sys_proto.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "mlib_SysMath.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#if ! defined ( __MEDIALIB_OLD_NAMES )
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#if defined ( __SUNPRO_C )
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#pragma weak mlib_memmove = __mlib_memmove
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#pragma weak mlib_malloc = __mlib_malloc
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#pragma weak mlib_realloc = __mlib_realloc
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#pragma weak mlib_free = __mlib_free
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
#pragma weak mlib_memset = __mlib_memset
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#pragma weak mlib_memcpy = __mlib_memcpy
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#ifdef MLIB_NO_LIBSUNMATH
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#pragma weak mlib_sincosf = __mlib_sincosf
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#endif /* MLIB_NO_LIBSUNMATH */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
#elif defined ( __GNUC__ ) /* defined ( __SUNPRO_C ) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
  __typeof__ ( __mlib_memmove) mlib_memmove
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    __attribute__ ((weak,alias("__mlib_memmove")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
  __typeof__ ( __mlib_malloc) mlib_malloc
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    __attribute__ ((weak,alias("__mlib_malloc")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
  __typeof__ ( __mlib_realloc) mlib_realloc
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    __attribute__ ((weak,alias("__mlib_realloc")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
  __typeof__ ( __mlib_free) mlib_free
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    __attribute__ ((weak,alias("__mlib_free")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
  __typeof__ ( __mlib_memset) mlib_memset
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    __attribute__ ((weak,alias("__mlib_memset")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
  __typeof__ ( __mlib_memcpy) mlib_memcpy
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    __attribute__ ((weak,alias("__mlib_memcpy")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
#ifdef MLIB_NO_LIBSUNMATH
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
void __mlib_sincosf (float x, float *s, float *c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
__typeof__ ( __mlib_sincosf) mlib_sincosf
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    __attribute__ ((weak,alias("__mlib_sincosf")));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
#endif /* MLIB_NO_LIBSUNMATH */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
#else /* defined ( __SUNPRO_C ) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
#error  "unknown platform"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
#endif /* defined ( __SUNPRO_C ) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
/***************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
void *__mlib_malloc(mlib_u32 size)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
#ifdef _MSC_VER
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
  /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
   * Currently, all MS C compilers for Win32 platforms default to 8 byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
   * alignment. -- from stdlib.h of MS VC++5.0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
  return (void *) memalign(8, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
#endif /* _MSC_VER */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
void *__mlib_realloc(void *ptr, mlib_u32 size)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
  return realloc(ptr, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
void __mlib_free(void *ptr)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
  free(ptr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
void *__mlib_memset(void *s, mlib_s32 c, mlib_u32 n)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
  return memset(s, c, n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
void *__mlib_memcpy(void *s1, void *s2, mlib_u32 n)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
  return memcpy(s1, s2, n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
void *__mlib_memmove(void *s1, void *s2, mlib_u32 n)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
  return memmove(s1, s2, n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
#ifdef MLIB_NO_LIBSUNMATH
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
void __mlib_sincosf (mlib_f32 x, mlib_f32 *s, mlib_f32 *c)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
  *s = (mlib_f32)sin(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
  *c = (mlib_f32)cos(x);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
#endif /* MLIB_NO_LIBSUNMATH */