/* 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 Digital Equipment Corporation 1996. All rights reserved.
//
//  Restricted Rights: Use, duplication, or disclosure by the U.S.
//  Government is subject to restrictions as set forth in subparagraph
//  (c) (1) (ii) of DFARS 252.227-7013, or in FAR 52.227-19, or in FAR
//  52.227-14 Alt. III, as applicable.
//
//  This software is proprietary to and embodies the confidential
//  technology of Digital Equipment Corporation. Possession, use, or
//  copying of this software and media is authorized only pursuant to a
//  valid written license from Digital or an authorized sublicensor.
//
//

#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 */


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

namespace std {

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 */

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

#else

namespace std {

  typedef void (*new_handler)();
  new_handler set_new_handler(new_handler) _RWSTD_THROW_SPEC_NULL;
  struct nothrow_t { };
  // Declaration of object nothrow to permit the use of the placement new
  // syntax: new (nothrow) T;
  const nothrow_t nothrow = {};

}  /* namespace std */

// 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. */
using namespace std;
#endif 

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

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

/*
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

/*
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 

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

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



#endif // __NOSTDNEW

#ifdef __PRAGMA_ENVIRONMENT
#   pragma __environment restore
#endif

#endif                                  /* __NEW_LOADED */
