Mercurial > ecos
annotate packages/infra/current/src/delete.cxx @ 66:bf00f99aec69 ecos-sw-2000-02-02
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
| author | jlarmour |
|---|---|
| date | Wed, 02 Feb 2000 19:57:02 +0000 |
| parents | c38311975d4f |
| children | 6ed91473a1cd |
| rev | line source |
|---|---|
| 0 | 1 //========================================================================== |
| 2 // | |
| 3 // common/delete.cxx | |
| 4 // | |
| 5 // Default delete implementation | |
| 6 // | |
| 7 //========================================================================== | |
| 8 //####COPYRIGHTBEGIN#### | |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
9 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
10 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
11 // The contents of this file are subject to the Red Hat eCos Public License |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
12 // Version 1.1 (the "License"); you may not use this file except in |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
13 // compliance with the License. You may obtain a copy of the License at |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
14 // http://www.redhat.com/ |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
15 // |
|
66
bf00f99aec69
Merge from eCos master repository on 2000-02-02-19:16:44-GMT
jlarmour
parents:
64
diff
changeset
|
16 // Software distributed under the License is distributed on an "AS IS" |
|
64
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
18 // License for the specific language governing rights and limitations under |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
19 // the License. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
20 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
21 // The Original Code is eCos - Embedded Configurable Operating System, |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
22 // released September 30, 1998. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
23 // |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
24 // The Initial Developer of the Original Code is Red Hat. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
25 // Portions created by Red Hat are |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
27 // All Rights Reserved. |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
28 // ------------------------------------------- |
|
c38311975d4f
Merge from eCos master repository on 2000-01-28-04:28:11-GMT
jlarmour
parents:
2
diff
changeset
|
29 // |
| 0 | 30 //####COPYRIGHTEND#### |
| 31 //========================================================================== | |
| 32 //#####DESCRIPTIONBEGIN#### | |
| 33 // | |
| 2 | 34 // Author(s): jlarmour |
| 35 // Contributors: jlarmour | |
| 0 | 36 // Date: 1999-08-13 |
| 37 // Purpose: Gives a default delete operation if the C library isn't present | |
| 38 // Description: This file supplies a definition of the default delete | |
| 39 // operation (aka __builtin_delete and __builtin_vec_delete) | |
| 40 // for use when the normal delete can't be used - normally when | |
| 41 // the C library is not present | |
| 42 // | |
| 43 //####DESCRIPTIONEND#### | |
| 44 // | |
| 45 //========================================================================== | |
| 46 | |
| 47 #include <pkgconf/system.h> | |
| 48 | |
| 49 #include <cyg/infra/cyg_type.h> | |
| 50 | |
| 51 // The configuration here is as follows: | |
| 52 // | |
| 53 // To deal with virtual destructors, where the correct delete() function | |
| 54 // must be called for the derived class in question, the underlying delete | |
| 55 // is called when needed, from destructors. This is regardless of whether | |
| 56 // the destructor is called by delete itself. So there is a reference to | |
| 57 // delete() from all destructors. The default builtin delete() attempts to | |
| 58 // call free() if there is one defined. So, if you have destructors, and | |
| 59 // you have free(), as in malloc() and free() in the C library, any | |
| 60 // destructor counts as a reference to free(). So the libc heap system is | |
| 61 // linked in regardless of whether it gets explicitly called. | |
| 62 // | |
| 63 // To defeat this undesirable behaviour, we define empty versions of delete | |
| 64 // and delete[]. But doing this prevents proper use of the libc heap in | |
| 65 // C++ programs via C++'s new and delete operators. | |
| 66 // | |
| 67 // Therefore, configuration is provided (in the libc package, near malloc | |
| 68 // et al) for explicitly disabling the provision of these empty functions, | |
| 69 // so that new and delete can be used, if that's what's required. | |
| 70 // | |
| 71 // It is also possible to override all this complexity anyway, but that is | |
| 72 // not yet represented in an external config option. | |
| 73 | |
| 74 | |
| 75 | |
| 76 // If this is already externally defined, go ahead and override the | |
| 77 // builtin delete functions. | |
| 78 #ifndef CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS | |
| 79 | |
| 80 # define CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS | |
| 81 # ifdef CYGPKG_LIBC | |
| 82 // then there is a libc: if there is a malloc, maybe do not supply empty | |
| 83 // delete functions. Get the libc config info to find out. | |
| 84 | |
| 85 # include <pkgconf/libc.h> | |
| 86 | |
| 87 // So, do NOT provide these functions if there is a malloc and we are not | |
| 88 // to provide these functions: | |
| 89 # ifdef CYGPKG_LIBC_MALLOC | |
| 90 # ifdef CYGIMP_LIBC_MALLOC_CXX_DELETE_CALLS_FREE | |
| 91 # undef CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS | |
| 92 # endif // CYGIMP_LIBC_MALLOC_CXX_DELETE_CALLS_FREE | |
| 93 # endif // CYGPKG_LIBC_MALLOC | |
| 94 # endif // CYGPKG_LIBC | |
| 95 #endif // CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS not already defined | |
| 96 | |
| 97 #ifdef CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS | |
| 98 // then define these empty functions: | |
| 99 | |
| 100 void operator delete(void *x) throw() | |
| 101 { | |
| 102 CYG_EMPTY_STATEMENT; | |
| 103 } | |
| 104 | |
| 105 void operator delete[](void *x) throw() | |
| 106 { | |
| 107 CYG_EMPTY_STATEMENT; | |
| 108 } | |
| 109 | |
| 110 #endif // CYGFUN_INFRA_EMPTY_DELETE_FUNCTIONS | |
| 111 | |
| 112 // EOF delete.cxx |
