00001 /* 00002 00003 Copyright (C) 1999-2001, Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2.1 of the GNU Lesser General Public License 00007 as published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Further, any 00012 license provided herein, whether implied or otherwise, is limited to 00013 this program in accordance with the express provisions of the 00014 GNU Lesser General Public License. 00015 00016 Patent licenses, if any, provided herein do not apply to combinations 00017 of this program with other product or programs, or any other product 00018 whatsoever. This program is distributed without any warranty that the 00019 program is delivered free of the rightful claim of any third person by 00020 way of infringement or the like. 00021 00022 See the GNU Lesser General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with this program; if not, write the Free Software Foundation, Inc., 59 00026 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00027 00028 */ 00029 00030 /* $Header: /proj/osprey/CVS/open64/osprey1.0/libU77/malloc_.c,v 1.1.1.1 2005/10/21 19:00:00 marcel Exp $ */ 00031 00032 #include <sys/types.h> 00033 #if defined(BUILD_OS_DARWIN) 00034 #include <stdlib.h> 00035 #else /* defined(BUILD_OS_DARWIN) */ 00036 #include <malloc.h> 00037 #endif /* defined(BUILD_OS_DARWIN) */ 00038 00039 /* 00040 #define NaN_single 0x7fbfffff; 00041 */ 00042 #define NaN_single 0xfffa5a5a; 00043 #define NaN_single_byte_0 0x5a; 00044 #define NaN_single_byte_1 0x5a; 00045 #define NaN_single_byte_2 0xfa; 00046 00047 extern char *mips__nan_malloc_(int *sz) 00048 { 00049 char *p; 00050 int *q; 00051 size_t roundoff_size; 00052 00053 roundoff_size = sizeof(int) * ((*sz + sizeof(int) - 1)/sizeof(int)); 00054 p = (char *) malloc(roundoff_size); 00055 q = (int *) (p + roundoff_size); 00056 while (q > (int *) p) { 00057 *--q = NaN_single; 00058 } 00059 return (p + (roundoff_size-*sz)); 00060 } 00061 00062 void *__trapuv_malloc(size_t size) 00063 { 00064 void *p; 00065 int *q; 00066 size_t roundoff_size; 00067 00068 roundoff_size = sizeof(int) * ((size + sizeof(int) - 1)/sizeof(int)); 00069 p = malloc(roundoff_size); 00070 q = (int *) ((char *)p + roundoff_size); 00071 while (q > (int *) p) { 00072 *--q = NaN_single; 00073 } 00074 return (void *)((char *)p + (roundoff_size-size)); 00075 }
1.5.6