source: trunk/third/gcc/objc/misc.c @ 8834

Revision 8834, 2.1 KB checked in by ghudson, 28 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r8833, which included commits to RCS files with non-trunk default branches.
Line 
1/* GNU Objective C Runtime Miscellaneous
2   Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
3
4Author: Kresten Krab Thorup
5
6This file is part of GNU CC.
7
8GNU CC is free software; you can redistribute it and/or modify it
9under the terms of the GNU General Public License as published by the
10Free Software Foundation; either version 2, or (at your option) any
11later version.
12
13GNU CC is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16for more details.
17
18You should have received a copy of the GNU General Public License
19along with GNU CC; see the file COPYING.  If not, write to the Free
20Software Foundation, 59 Temple Place - Suite 330,
21Boston, MA 02111-1307, USA.  */
22
23/* As a special exception, if you link this library with files compiled with
24   GCC to produce an executable, this does not cause the resulting executable
25   to be covered by the GNU General Public License. This exception does not
26   however invalidate any other reasons why the executable file might be
27   covered by the GNU General Public License.  */
28
29#ifdef __alpha__
30#include <stdlib.h>
31extern int write (int, const char*, int);
32extern size_t strlen (const char*);
33#endif
34
35#include "runtime.h"
36
37void objc_error(id object, const char* fmt, va_list);
38
39void (*_objc_error)(id, const char*, va_list) = objc_error;
40
41void
42objc_error(id object, const char* fmt, va_list ap)
43{
44  vfprintf (stderr, fmt, ap);
45  abort ();
46}
47
48volatile void
49objc_fatal(const char* msg)
50{
51  write(2, msg, (int)strlen((const char*)msg));
52  abort();
53}
54
55void*
56__objc_xmalloc(size_t size)
57{
58  void* res = (void*) malloc(size);
59  if(!res)
60    objc_fatal("Virtual memory exhausted\n");
61  return res;
62}
63
64void*
65__objc_xrealloc(void* mem, size_t size)
66{
67  void* res = (void*) realloc(mem, size);
68  if(!res)
69    objc_fatal("Virtual memory exhausted\n");
70  return res;
71}
72
73void*
74__objc_xcalloc(size_t nelem, size_t size)
75{
76  void* res = (void*)calloc(nelem, size);
77  if(!res)
78    objc_fatal("Virtual memory exhausted\n");
79  return res;
80}
Note: See TracBrowser for help on using the repository browser.