Add engine
This commit is contained in:
parent
5815184863
commit
28745079d3
|
@ -3,6 +3,10 @@ Microsoft Visual Studio Solution File, Format Version 10.00
|
|||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "doubango", "doubango\doubango.vcproj", "{F31BBB1C-A0EB-46DE-B920-B843918E9090}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libsofia_sip_ua", "sofia-sip-1.12.10\win32\libsofia-sip-ua\libsofia_sip_ua.vcproj", "{0D85D39A-C7FB-4C52-A541-73665FB478E6}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcproj", "{D38BEAF4-2B25-49F4-97BC-3DC10440DC6D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
|
@ -13,6 +17,14 @@ Global
|
|||
{F31BBB1C-A0EB-46DE-B920-B843918E9090}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{F31BBB1C-A0EB-46DE-B920-B843918E9090}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{F31BBB1C-A0EB-46DE-B920-B843918E9090}.Release|Win32.Build.0 = Release|Win32
|
||||
{0D85D39A-C7FB-4C52-A541-73665FB478E6}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{0D85D39A-C7FB-4C52-A541-73665FB478E6}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{0D85D39A-C7FB-4C52-A541-73665FB478E6}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{0D85D39A-C7FB-4C52-A541-73665FB478E6}.Release|Win32.Build.0 = Release|Win32
|
||||
{D38BEAF4-2B25-49F4-97BC-3DC10440DC6D}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D38BEAF4-2B25-49F4-97BC-3DC10440DC6D}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D38BEAF4-2B25-49F4-97BC-3DC10440DC6D}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D38BEAF4-2B25-49F4-97BC-3DC10440DC6D}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="./src"
|
||||
AdditionalIncludeDirectories="./src;"$(SolutionDir)sofia-sip-1.12.10\win32";"$(SolutionDir)sofia-sip-1.12.10\libsofia-sip-ua\su";"$(SolutionDir)sofia-sip-1.12.10\libsofia-sip-ua\ipt";"$(SolutionDir)sofia-sip-1.12.10\libsofia-sip-ua\sresolv";"$(SolutionDir)sofia-sip-1.12.10\libsofia-sip-ua\bnf";"$(SolutionDir)sofia-sip-1.12.10\libsofia-sip-ua\url";"$(SolutionDir)sofia-sip-1.12.10\libsofia-sip-ua\msg";"$(SolutionDir)sofia-sip-1.12.10\libsofia-sip-ua\sip";"$(SolutionDir)sofia-sip-1.12.10\libsofia-sip-ua\nta";"$(SolutionDir)sofia-sip-1.12.10\libsofia-sip-ua\nua";"$(SolutionDir)sofia-sip-1.12.10\libsofia-sip-ua\iptsec";"$(SolutionDir)sofia-sip-1.12.10\libsofia-sip-ua\http";"$(SolutionDir)sofia-sip-1.12.10\libsofia-sip-ua\nth";"$(SolutionDir)sofia-sip-1.12.10\libsofia-sip-ua\nea";"$(SolutionDir)sofia-sip-1.12.10\libsofia-sip-ua\sdp";"$(SolutionDir)sofia-sip-1.12.10\libsofia-sip-ua\soa";"$(SolutionDir)sofia-sip-1.12.10\libsofia-sip-ua\stun";"$(SolutionDir)sofia-sip-1.12.10\libsofia-sip-ua\tport""
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DOUBANGO_EXPORTS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
|
@ -61,6 +61,7 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="$(OutDir)\libsofia_sip_ua.lib"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="2"
|
||||
|
@ -169,10 +170,6 @@
|
|||
<Filter
|
||||
Name="source"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\test.cxx"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="sip_dialogs"
|
||||
>
|
||||
|
@ -241,6 +238,18 @@
|
|||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="api"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\api_engine.cxx"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\api_stack.cxx"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="include"
|
||||
|
@ -257,10 +266,6 @@
|
|||
RelativePath=".\src\pref.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\stdint0.h"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="sip_dialogs"
|
||||
>
|
||||
|
@ -329,6 +334,22 @@
|
|||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="api"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\api_engine.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\api_errors.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\api_stack.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="sm"
|
||||
|
|
|
@ -0,0 +1,146 @@
|
|||
#include "api_engine.h"
|
||||
|
||||
/* TODO: add mutex */
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <list>
|
||||
|
||||
#include <sofia-sip/su.h>
|
||||
|
||||
#define PSTACK stack*
|
||||
|
||||
PREF_NAMESPACE_START
|
||||
|
||||
/* engine callback declaration */
|
||||
static void engine_callback(nua_event_t event,
|
||||
int status,
|
||||
char const *phrase,
|
||||
nua_t *nua,
|
||||
nua_magic_t *magic,
|
||||
nua_handle_t *nh,
|
||||
nua_hmagic_t *hmagic,
|
||||
sip_t const *sip,
|
||||
tagi_t tags[]);
|
||||
|
||||
/* global variable holding engine initialization state */
|
||||
static bool __initialized = false;
|
||||
|
||||
/* global variable holding all stacks */
|
||||
static std::list<PSTACK> __stacks;
|
||||
|
||||
/* predicate: find stack by id */
|
||||
struct pred_stack_find_by_id: public std::binary_function< PSTACK, int, bool > {
|
||||
bool operator () ( const PSTACK s, const int &id ) const {
|
||||
return s->get_id() == id;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* initialize engine (system utilities) */
|
||||
ERR engine_initialize()
|
||||
{
|
||||
if(__initialized) return ERR_ENGINE_ALREADY_INITIALIZED;
|
||||
|
||||
if( !su_init() )
|
||||
{
|
||||
__initialized = true;
|
||||
return ERR_SUCCESS;
|
||||
}
|
||||
|
||||
return ERR_GLOBAL_FAILURE;
|
||||
}
|
||||
|
||||
/* deinitialize engine (system utilities) */
|
||||
ERR engine_deinitialize()
|
||||
{
|
||||
if(!__initialized) return ERR_ENGINE_NOT_INITIALIZED;
|
||||
|
||||
std::list<PSTACK>::iterator iter = __stacks.begin();
|
||||
for ( ; iter!=__stacks.end(); iter++ )
|
||||
{
|
||||
delete(*iter);
|
||||
}
|
||||
__stacks.clear();
|
||||
|
||||
su_deinit();
|
||||
|
||||
__initialized = false;
|
||||
return ERR_SUCCESS;
|
||||
}
|
||||
|
||||
/* creates a stack with the specified id */
|
||||
ERR engine_stack_create(int stack_id)
|
||||
{
|
||||
if(!__initialized) return ERR_ENGINE_NOT_INITIALIZED;
|
||||
|
||||
if(engine_stack_find(stack_id))
|
||||
{
|
||||
return ERR_STACK_ALREADY_EXIST;
|
||||
}
|
||||
stack* sk = new stack(stack_id, engine_callback);
|
||||
if(sk->get_initialized())
|
||||
{
|
||||
__stacks.push_back(sk);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete sk;
|
||||
return ERR_STACK_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
return ERR_SUCCESS;
|
||||
}
|
||||
|
||||
/* runs the stack with the specified id */
|
||||
ERR engine_stack_run(int stack_id)
|
||||
{
|
||||
if(!__initialized) return ERR_ENGINE_NOT_INITIALIZED;
|
||||
|
||||
return ERR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* shutdown downs the stack with the specified id */
|
||||
ERR engine_stack_shutdown(int stack_id)
|
||||
{
|
||||
if(!__initialized) return ERR_ENGINE_NOT_INITIALIZED;
|
||||
|
||||
return ERR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* shutdown downs all stacks */
|
||||
ERR engine_stack_shutdown_all(void)
|
||||
{
|
||||
if(!__initialized) return ERR_ENGINE_NOT_INITIALIZED;
|
||||
|
||||
return ERR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* find stack by id*/
|
||||
stack* engine_stack_find(int stack_id)
|
||||
{
|
||||
std::list<PSTACK>::iterator iter = __stacks.begin();
|
||||
iter = std::find_if( iter, __stacks.end(), std::bind2nd( pred_stack_find_by_id(), stack_id ) );
|
||||
if(iter != __stacks.end())
|
||||
{
|
||||
return *iter;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* engine callback*/
|
||||
void engine_callback(nua_event_t event,
|
||||
int status,
|
||||
char const *phrase,
|
||||
nua_t *nua,
|
||||
nua_magic_t *magic,
|
||||
nua_handle_t *nh,
|
||||
nua_hmagic_t *hmagic,
|
||||
sip_t const *sip,
|
||||
tagi_t tags[])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#undef PSTACK
|
||||
|
||||
PREF_NAMESPACE_END
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef _DOUBANGO_API_ENGINE_H_
|
||||
#define _DOUBANGO_API_ENGINE_H_
|
||||
|
||||
#include "pref.h"
|
||||
#include "api_errors.h"
|
||||
#include "api_stack.h"
|
||||
|
||||
PREF_NAMESPACE_START
|
||||
|
||||
DOUBANGO_API_C ERR engine_initialize(void);
|
||||
DOUBANGO_API_C ERR engine_deinitialize(void);
|
||||
|
||||
DOUBANGO_API_C ERR engine_stack_create(int stack_id);
|
||||
DOUBANGO_API_C ERR engine_stack_run(int stack_id);
|
||||
DOUBANGO_API_C ERR engine_stack_shutdown(int stack_id);
|
||||
DOUBANGO_API_C ERR engine_stack_shutdown_all(void);
|
||||
|
||||
stack* engine_stack_find(int stack_id);
|
||||
|
||||
PREF_NAMESPACE_END
|
||||
|
||||
#endif /* _DOUBANGO_API_ENGINE_H_ */
|
|
@ -0,0 +1,33 @@
|
|||
#ifndef _DOUBANGO_ERRORS_H_
|
||||
#define _DOUBANGO_ERRORS_H_
|
||||
|
||||
#include "pref.h"
|
||||
|
||||
PREF_NAMESPACE_START
|
||||
|
||||
#define ERR_SUCCEED(code) (code == PREF_NAMESPACE_VALUE::ERR_SUCCESS)
|
||||
#define ERR_FAILED(code) !ERR_SUCCEED(code)
|
||||
|
||||
typedef enum tag_ERR
|
||||
{
|
||||
ERR_SUCCESS = 0x0000,
|
||||
|
||||
ERR_GLOBAL_FAILURE = -0xFFFF,
|
||||
ERR_NOT_IMPLEMENTED,
|
||||
ERR_FUNC_OBSOLETE,
|
||||
|
||||
/* ENGINE errors */
|
||||
ERR_ENGINE_NOT_INITIALIZED, /* engine not initialized or initialization failed*/
|
||||
ERR_ENGINE_ALREADY_INITIALIZED, /* engine have been already initialized */
|
||||
|
||||
/* STACK errors */
|
||||
ERR_STACK_ALREADY_EXIST,
|
||||
ERR_STACK_NOT_INITIALIZED, /* stack not initialized or initialization failed*/
|
||||
ERR_STACK_IS_INVALID, /* stack is in an invalide state (NULL, destroyed, locked, ...) */
|
||||
ERR_STACK_NOT_RUNNING, /* operation failed because the stack is not running */
|
||||
}
|
||||
ERR;
|
||||
|
||||
PREF_NAMESPACE_END
|
||||
|
||||
#endif /* _DOUBANGO_ERRORS_H_ */
|
|
@ -0,0 +1,69 @@
|
|||
#include "api_stack.h"
|
||||
|
||||
PREF_NAMESPACE_START
|
||||
|
||||
/* stack constructor */
|
||||
stack::stack(int _id, nua_callback_f callback): id(_id), initialized(false)
|
||||
{
|
||||
// initialize memory handling
|
||||
if( su_home_init(this->home) ) return;
|
||||
|
||||
// initialize root object
|
||||
this->root = su_root_create(this);
|
||||
if(!this->root)
|
||||
{
|
||||
su_home_deinit(this->home);
|
||||
return;
|
||||
}
|
||||
|
||||
// create NUA stack
|
||||
this->nua = nua_create(this->root, callback, this,
|
||||
/* tags as necessary ...*/
|
||||
TAG_NULL());
|
||||
if (!this->nua)
|
||||
{
|
||||
su_root_destroy(this->root);
|
||||
su_home_deinit(this->home);
|
||||
return;
|
||||
}
|
||||
|
||||
// set necessary parameters
|
||||
nua_set_params(this->nua,
|
||||
/* tags as necessary ...*/
|
||||
TAG_NULL());
|
||||
|
||||
// enter main loop for processing of messages
|
||||
su_root_run(this->root);
|
||||
|
||||
this->initialized = true;
|
||||
}
|
||||
|
||||
/* stack destructor */
|
||||
stack::~stack()
|
||||
{
|
||||
if(this->initialized)
|
||||
{
|
||||
// destroy NUA stack
|
||||
nua_destroy(this->nua);
|
||||
|
||||
// deinit root object
|
||||
su_root_destroy(this->root);
|
||||
|
||||
// deinitialize memory handling
|
||||
su_home_deinit(this->home);
|
||||
}
|
||||
}
|
||||
|
||||
/* gets the stack id */
|
||||
inline int stack::get_id()const
|
||||
{
|
||||
return this->id;
|
||||
}
|
||||
|
||||
/* returns true if initialized, false otherwise */
|
||||
inline bool stack::get_initialized() const
|
||||
{
|
||||
return this->initialized;
|
||||
}
|
||||
|
||||
PREF_NAMESPACE_END
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef __DOUBANGO_STACK_H__
|
||||
#define __DOUBANGO_STACK_H__
|
||||
|
||||
#include "pref.h"
|
||||
#include <sofia-sip/nua.h>
|
||||
|
||||
PREF_NAMESPACE_START
|
||||
|
||||
class DOUBANGO_API stack
|
||||
{
|
||||
public:
|
||||
stack(int id, nua_callback_f callback);
|
||||
~stack();
|
||||
|
||||
inline int get_id() const;
|
||||
inline bool get_initialized() const;
|
||||
|
||||
private:
|
||||
int id;
|
||||
bool initialized;
|
||||
|
||||
su_home_t home[1]; /* memory home */
|
||||
su_root_t *root; /* root object */
|
||||
nua_t *nua; /* NUA stack object */
|
||||
};
|
||||
|
||||
PREF_NAMESPACE_END
|
||||
|
||||
#endif /* __DOUBANGO_STACK_H__ */
|
|
@ -28,6 +28,9 @@
|
|||
#ifndef __DOUBANGO_DOUBANGO_H__
|
||||
#define __DOUBANGO_DOUBANGO_H__
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "api_engine.h"
|
||||
}
|
||||
|
||||
#endif /* __DOUBANGO_DOUBANGO_H__ */
|
|
@ -31,6 +31,26 @@
|
|||
#define PREF_NAMESPACE_USE 1
|
||||
#define PREF_NAMESPACE_VALUE dgo
|
||||
|
||||
/* doubango api funtions export */
|
||||
#if defined(WIN32) || defined(__SYMBIAN32__)
|
||||
# ifdef DOUBANGO_EXPORTS
|
||||
# define DOUBANGO_API __declspec(dllexport)
|
||||
# define DOUBANGO_API_C extern "C" DOUBANGO_API
|
||||
# else
|
||||
# define DOUBANGO_API __declspec(dllimport)
|
||||
# define DOUBANGO_API_C
|
||||
# endif
|
||||
#else
|
||||
# define DOUBANGO_API
|
||||
# define DOUBANGO_API_C
|
||||
#endif
|
||||
|
||||
/* disable warnings */
|
||||
#ifdef WIN32
|
||||
#pragma warning( disable : 4132 4100 4127 4152 4355 4996)
|
||||
#endif
|
||||
|
||||
/* namespace definition*/
|
||||
#if PREF_NAMESPACE_USE
|
||||
# define PREF_NAMESPACE_START namespace PREF_NAMESPACE_VALUE {
|
||||
# define PREF_NAMESPACE_END }
|
||||
|
|
|
@ -44,6 +44,8 @@
|
|||
// (See bottom of file)
|
||||
//
|
||||
|
||||
#include "pref.h"
|
||||
|
||||
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
|
||||
#include <iostream>
|
||||
#if defined(SMC_NO_EXCEPTIONS)
|
||||
|
|
|
@ -1,268 +0,0 @@
|
|||
/*
|
||||
** Copyright (C) 2009 Doubango Telecom <imsframework(at)gmail.com>
|
||||
|
||||
This file is part of 'Doubango IMS Client Framework'.
|
||||
|
||||
'Doubango IMS Client Framework' is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
'Doubango IMS Client Framework' is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with 'Doubango IMS Client Framework'. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
** For commercial use, you must purchase a proprietary license from Doubango Telecom.
|
||||
*/
|
||||
|
||||
// ISO C9x compliant stdint.h for Microsoft Visual Studio
|
||||
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
|
||||
//
|
||||
// Copyright (c) 2006-2008 Alexander Chemeris
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// 1. Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// 2. Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// 3. The name of the author may be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _MSC_VER // [
|
||||
#error "Use this header only with Microsoft Visual C++ compilers!"
|
||||
#endif // _MSC_VER ]
|
||||
|
||||
#ifndef _MSC_STDINT_H_ // [
|
||||
#define _MSC_STDINT_H_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
// For Visual Studio 6 in C++ mode and for many Visual Studio versions when
|
||||
// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}'
|
||||
// or compiler give many errors like this:
|
||||
// error C2733: second C linkage of overloaded function 'wmemchr' not allowed
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
# include <wchar.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
// Define _W64 macros to mark types changing their size, like intptr_t.
|
||||
#ifndef _W64
|
||||
# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
|
||||
# define _W64 __w64
|
||||
# else
|
||||
# define _W64
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
// 7.18.1 Integer types
|
||||
|
||||
// 7.18.1.1 Exact-width integer types
|
||||
|
||||
// Visual Studio 6 and Embedded Visual C++ 4 doesn't
|
||||
// realize that, e.g. char has the same size as __int8
|
||||
// so we give up on __intX for them.
|
||||
#if (_MSC_VER < 1300)
|
||||
typedef signed char int8_t;
|
||||
typedef signed short int16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
#else
|
||||
typedef signed __int8 int8_t;
|
||||
typedef signed __int16 int16_t;
|
||||
typedef signed __int32 int32_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
#endif
|
||||
typedef signed __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
|
||||
|
||||
// 7.18.1.2 Minimum-width integer types
|
||||
typedef int8_t int_least8_t;
|
||||
typedef int16_t int_least16_t;
|
||||
typedef int32_t int_least32_t;
|
||||
typedef int64_t int_least64_t;
|
||||
typedef uint8_t uint_least8_t;
|
||||
typedef uint16_t uint_least16_t;
|
||||
typedef uint32_t uint_least32_t;
|
||||
typedef uint64_t uint_least64_t;
|
||||
|
||||
// 7.18.1.3 Fastest minimum-width integer types
|
||||
typedef int8_t int_fast8_t;
|
||||
typedef int16_t int_fast16_t;
|
||||
typedef int32_t int_fast32_t;
|
||||
typedef int64_t int_fast64_t;
|
||||
typedef uint8_t uint_fast8_t;
|
||||
typedef uint16_t uint_fast16_t;
|
||||
typedef uint32_t uint_fast32_t;
|
||||
typedef uint64_t uint_fast64_t;
|
||||
|
||||
// 7.18.1.4 Integer types capable of holding object pointers
|
||||
#ifdef _WIN64 // [
|
||||
typedef signed __int64 intptr_t;
|
||||
typedef unsigned __int64 uintptr_t;
|
||||
#else // _WIN64 ][
|
||||
typedef _W64 signed int intptr_t;
|
||||
typedef _W64 unsigned int uintptr_t;
|
||||
#endif // _WIN64 ]
|
||||
|
||||
// 7.18.1.5 Greatest-width integer types
|
||||
typedef int64_t intmax_t;
|
||||
typedef uint64_t uintmax_t;
|
||||
|
||||
|
||||
// 7.18.2 Limits of specified-width integer types
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259
|
||||
|
||||
// 7.18.2.1 Limits of exact-width integer types
|
||||
#define INT8_MIN ((int8_t)_I8_MIN)
|
||||
#define INT8_MAX _I8_MAX
|
||||
#define INT16_MIN ((int16_t)_I16_MIN)
|
||||
#define INT16_MAX _I16_MAX
|
||||
#define INT32_MIN ((int32_t)_I32_MIN)
|
||||
#define INT32_MAX _I32_MAX
|
||||
#define INT64_MIN ((int64_t)_I64_MIN)
|
||||
#define INT64_MAX _I64_MAX
|
||||
#define UINT8_MAX _UI8_MAX
|
||||
#define UINT16_MAX _UI16_MAX
|
||||
#define UINT32_MAX _UI32_MAX
|
||||
#define UINT64_MAX _UI64_MAX
|
||||
|
||||
// 7.18.2.2 Limits of minimum-width integer types
|
||||
#define INT_LEAST8_MIN INT8_MIN
|
||||
#define INT_LEAST8_MAX INT8_MAX
|
||||
#define INT_LEAST16_MIN INT16_MIN
|
||||
#define INT_LEAST16_MAX INT16_MAX
|
||||
#define INT_LEAST32_MIN INT32_MIN
|
||||
#define INT_LEAST32_MAX INT32_MAX
|
||||
#define INT_LEAST64_MIN INT64_MIN
|
||||
#define INT_LEAST64_MAX INT64_MAX
|
||||
#define UINT_LEAST8_MAX UINT8_MAX
|
||||
#define UINT_LEAST16_MAX UINT16_MAX
|
||||
#define UINT_LEAST32_MAX UINT32_MAX
|
||||
#define UINT_LEAST64_MAX UINT64_MAX
|
||||
|
||||
// 7.18.2.3 Limits of fastest minimum-width integer types
|
||||
#define INT_FAST8_MIN INT8_MIN
|
||||
#define INT_FAST8_MAX INT8_MAX
|
||||
#define INT_FAST16_MIN INT16_MIN
|
||||
#define INT_FAST16_MAX INT16_MAX
|
||||
#define INT_FAST32_MIN INT32_MIN
|
||||
#define INT_FAST32_MAX INT32_MAX
|
||||
#define INT_FAST64_MIN INT64_MIN
|
||||
#define INT_FAST64_MAX INT64_MAX
|
||||
#define UINT_FAST8_MAX UINT8_MAX
|
||||
#define UINT_FAST16_MAX UINT16_MAX
|
||||
#define UINT_FAST32_MAX UINT32_MAX
|
||||
#define UINT_FAST64_MAX UINT64_MAX
|
||||
|
||||
// 7.18.2.4 Limits of integer types capable of holding object pointers
|
||||
#ifdef _WIN64 // [
|
||||
# define INTPTR_MIN INT64_MIN
|
||||
# define INTPTR_MAX INT64_MAX
|
||||
# define UINTPTR_MAX UINT64_MAX
|
||||
#else // _WIN64 ][
|
||||
# define INTPTR_MIN INT32_MIN
|
||||
# define INTPTR_MAX INT32_MAX
|
||||
# define UINTPTR_MAX UINT32_MAX
|
||||
#endif // _WIN64 ]
|
||||
|
||||
// 7.18.2.5 Limits of greatest-width integer types
|
||||
#define INTMAX_MIN INT64_MIN
|
||||
#define INTMAX_MAX INT64_MAX
|
||||
#define UINTMAX_MAX UINT64_MAX
|
||||
|
||||
// 7.18.3 Limits of other integer types
|
||||
|
||||
#ifdef _WIN64 // [
|
||||
# define PTRDIFF_MIN _I64_MIN
|
||||
# define PTRDIFF_MAX _I64_MAX
|
||||
#else // _WIN64 ][
|
||||
# define PTRDIFF_MIN _I32_MIN
|
||||
# define PTRDIFF_MAX _I32_MAX
|
||||
#endif // _WIN64 ]
|
||||
|
||||
#define SIG_ATOMIC_MIN INT_MIN
|
||||
#define SIG_ATOMIC_MAX INT_MAX
|
||||
|
||||
#ifndef SIZE_MAX // [
|
||||
# ifdef _WIN64 // [
|
||||
# define SIZE_MAX _UI64_MAX
|
||||
# else // _WIN64 ][
|
||||
# define SIZE_MAX _UI32_MAX
|
||||
# endif // _WIN64 ]
|
||||
#endif // SIZE_MAX ]
|
||||
|
||||
// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>
|
||||
#ifndef WCHAR_MIN // [
|
||||
# define WCHAR_MIN 0
|
||||
#endif // WCHAR_MIN ]
|
||||
#ifndef WCHAR_MAX // [
|
||||
# define WCHAR_MAX _UI16_MAX
|
||||
#endif // WCHAR_MAX ]
|
||||
|
||||
#define WINT_MIN 0
|
||||
#define WINT_MAX _UI16_MAX
|
||||
|
||||
#endif // __STDC_LIMIT_MACROS ]
|
||||
|
||||
|
||||
// 7.18.4 Limits of other integer types
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260
|
||||
|
||||
// 7.18.4.1 Macros for minimum-width integer constants
|
||||
|
||||
#define INT8_C(val) val##i8
|
||||
#define INT16_C(val) val##i16
|
||||
#define INT32_C(val) val##i32
|
||||
#define INT64_C(val) val##i64
|
||||
|
||||
#define UINT8_C(val) val##ui8
|
||||
#define UINT16_C(val) val##ui16
|
||||
#define UINT32_C(val) val##ui32
|
||||
#define UINT64_C(val) val##ui64
|
||||
|
||||
// 7.18.4.2 Macros for greatest-width integer constants
|
||||
#define INTMAX_C INT64_C
|
||||
#define UINTMAX_C UINT64_C
|
||||
|
||||
#endif // __STDC_CONSTANT_MACROS ]
|
||||
|
||||
|
||||
#endif // _MSC_STDINT_H_ ]
|
|
@ -1,2 +0,0 @@
|
|||
#include "stdint0.h"
|
||||
#include "sm.h"
|
Loading…
Reference in New Issue