/* Edison Design Group, 1992. */
/*
new -- Include file for C++ default operator new (see ARM 12.5).
*/

/*
 Note: to facilitate header file processing on OpenVMS and Digital UNIX
 <new> and <new.hxx> must be identical.  Changes to one of these headers
 must be applied to the other.
*/

#ifndef __NEW_LOADED
#define __NEW_LOADED 1
//
//    
//  Copyright 2000 Compaq Computer Corporation
//
//  COMPAQ Registered in U.S. Patent and Trademark Office.
//
//  Confidential computer software. Valid license from Compaq required for
//  possession, use or copying. Consistent with FAR 12.211 and 12.212,
//  Commercial Computer Software, Computer Software Documentation, and
//  Technical Data for Commercial Items are licensed to the U.S. Government
//  under vendor's standard commercial license.
//
//

#include <stddef.h>
#include <exception>

#ifdef __PRAGMA_ENVIRONMENT
#   pragma __environment save
#   pragma __environment header_defaults
#endif

#ifdef __VMS
#   ifndef __SIZE_T
#      define __SIZE_T 1
       typedef unsigned int size_t;
#   endif
#endif /* __VMS */


#if defined(__VMS) && defined(__DECCXX) && !defined(__DECFIXCXXL1158)
#pragma __extern_prefix __save
#pragma __extern_prefix "CXXL$" 
#endif

#ifndef _RWSTD_NO_NAMESPACE
namespace std {
#endif

/* This lets users disable the EDG supplied exception classes. */
#ifndef __NO_EDG_EXCEPTION_CLASSES

class bad_alloc : public exception {
public:
    bad_alloc() _RWSTD_THROW_SPEC_NULL;
    bad_alloc(const bad_alloc&) _RWSTD_THROW_SPEC_NULL;
    bad_alloc& operator=(const bad_alloc&) _RWSTD_THROW_SPEC_NULL;
    virtual ~bad_alloc() _RWSTD_THROW_SPEC_NULL;
    virtual const char* what() const _RWSTD_THROW_SPEC_NULL;
};

#endif /* ifndef __NO_EDG_EXCEPTION_CLASSES */

struct nothrow_t { };
// Declaration of object nothrow to permit the use of the placement new
// syntax: new (nothrow) T;
const nothrow_t nothrow = {};

#ifndef _RWSTD_NO_NAMESPACE
}
#endif

/*
Nothrow version of operator new.
*/
void *operator new(size_t, const std::nothrow_t&) _RWSTD_THROW_SPEC_NULL;

#if defined(__DECCXX) && !defined(__DECFIXCXXL1024)
/*
Nothrow version of operator delete.
*/
void operator delete(void* ptr, const std::nothrow_t&) _RWSTD_THROW_SPEC_NULL;
#endif

/*
Nothrow version of array new.
*/
#ifdef __GLOBAL_ARRAY_NEW // tied to -global_array_new switch
void *operator new[](size_t,
                     const std::nothrow_t&) _RWSTD_THROW_SPEC_NULL;
#endif


#if defined(__DECCXX) && !defined(__DECFIXCXXL1024)
/*
Nothrow version of array delete.
*/
#ifdef __GLOBAL_ARRAY_NEW // tied to -global_array_new switch
void operator delete[](void* ptr, const std::nothrow_t&) _RWSTD_THROW_SPEC_NULL;
#endif
#endif



#if defined(__VMS) && defined(__DECCXX) && !defined(__DECFIXCXXL1158)
#   pragma __extern_prefix __restore
#endif


#ifndef __STDNEW
//
// Not compiled with -stdnew 
//
#ifdef __VMS
#   pragma __extern_prefix __save
#   pragma __extern_prefix "decc$"
#endif
    extern void (*set_new_handler (void(*)()))();
#ifdef __VMS
#   pragma __extern_prefix __restore
#endif
inline void* operator new(size_t, void* p) { return p; }

#else

#if defined(__VMS) && defined(__DECCXX) && !defined(__DECFIXCXXL1158)
#pragma __extern_prefix __save
#pragma __extern_prefix "CXXL$" 
#endif

#ifndef _RWSTD_NO_NAMESPACE
namespace std {
#endif

typedef void (*new_handler)();
new_handler set_new_handler(new_handler) _RWSTD_THROW_SPEC_NULL;

#ifndef _RWSTD_NO_NAMESPACE
}  /* namespace std */
#endif

// as soon as compiler is sync'ed, remove __EDG_IMPLICIT_USING_STD
#if defined(__EDG_IMPLICIT_USING_STD) || defined(__IMPLICIT_USING_STD)
/* Implicitly include a using directive for the STD namespace when this
   preprocessing flag is TRUE. */
#ifndef _RWSTD_NO_NAMESPACE
using namespace std;
#endif
#endif 

/*
Normal operator new routine.
*/
void *operator new(size_t) _RWSTD_THROW_SPEC((std::bad_alloc));


#if defined(__DECCXX) && !defined(__DECFIXCXXC6676)
/*
Normal operator delete routine.
*/

#ifndef __VMS
void operator delete(void* ptr) _RWSTD_THROW_SPEC_NULL;
#else
#   pragma __extern_prefix __save
#   pragma __extern_prefix "decc$"
void operator delete(void* ptr) _RWSTD_THROW_SPEC_NULL;
#   pragma __extern_prefix __restore
#endif
#endif


/*
Placement new.  This was not in the ARM, but it is now standard in
[lib.new.delete.placement].
*/
void *operator new(size_t, void*) _RWSTD_THROW_SPEC_NULL;

/*
Placement delete.
*/
#ifdef __EXCEPTIONS
void operator delete(void*, void*) _RWSTD_THROW_SPEC_NULL;
#endif 

/*
Array new.
*/
#ifdef __GLOBAL_ARRAY_NEW // tied to -global_array_new switch
void *operator new[](size_t) _RWSTD_THROW_SPEC((std::bad_alloc));
#endif

#if defined(__DECCXX) && !defined(__DECFIXCXXC6676)
/*
Array delete.
*/
#ifdef __GLOBAL_ARRAY_NEW // tied to -global_array_new switch
void operator delete[](void*) _RWSTD_THROW_SPEC_NULL;
#endif
#endif

/*
Placement array new.
*/
void *operator new[](size_t, void*) _RWSTD_THROW_SPEC_NULL;

/*
Placement array delete.
*/
#ifdef __EXCEPTIONS
void operator delete[](void*, void*) _RWSTD_THROW_SPEC_NULL;
#endif 


//
// implementation-defined default new handler
//
void __cxxl_default_new_handler() _RWSTD_THROW_SPEC((std::bad_alloc));

#if defined(__VMS) && defined(__DECCXX) && !defined(__DECFIXCXXL1158)
#   pragma __extern_prefix __restore
#endif

#endif // __NOSTDNEW

#ifdef __PRAGMA_ENVIRONMENT
#   pragma __environment restore
#endif

#endif                                  /* __NEW_LOADED */
