2005-12-29 17:25:28 +00:00
|
|
|
/*
|
|
|
|
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
|
|
|
* Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
|
|
|
|
*
|
|
|
|
* Version: MPL 1.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Anthony Minessale II <anthmct@yahoo.com>
|
|
|
|
* Portions created by the Initial Developer are Copyright (C)
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Anthony Minessale II <anthmct@yahoo.com>
|
|
|
|
*
|
|
|
|
* switch_platform.h -- Platform Specific Header
|
|
|
|
*
|
|
|
|
*/
|
2006-01-02 22:36:01 +00:00
|
|
|
/*! \file switch_platform.h
|
|
|
|
\brief Platform Specific Header
|
2006-01-01 15:23:12 +00:00
|
|
|
*/
|
2005-12-29 17:25:28 +00:00
|
|
|
#ifndef SWITCH_PLATFORM_H
|
|
|
|
#define SWITCH_PLATFORM_H
|
|
|
|
|
2006-09-07 14:23:31 +00:00
|
|
|
SWITCH_BEGIN_EXTERN_C
|
2005-12-29 17:25:28 +00:00
|
|
|
|
2006-03-30 23:02:50 +00:00
|
|
|
#ifdef __ICC
|
2006-03-31 16:48:58 +00:00
|
|
|
#pragma warning (disable:810 869 981 279 1469 188)
|
2006-03-30 23:02:50 +00:00
|
|
|
#endif
|
|
|
|
|
2006-04-12 15:25:26 +00:00
|
|
|
#include <stdio.h>
|
2006-12-19 00:41:20 +00:00
|
|
|
|
2006-12-19 19:41:07 +00:00
|
|
|
#ifdef _MSC_VER
|
2006-12-19 00:41:20 +00:00
|
|
|
#define __SWITCH_FUNC__ __FUNCTION__
|
|
|
|
#else
|
|
|
|
#define __SWITCH_FUNC__ (const char *)__func__
|
2006-12-18 00:48:34 +00:00
|
|
|
#endif
|
2006-04-12 15:25:26 +00:00
|
|
|
|
2007-03-09 20:44:13 +00:00
|
|
|
|
2006-02-20 00:23:25 +00:00
|
|
|
#ifdef _MSC_VER
|
2006-03-10 08:48:47 +00:00
|
|
|
|
|
|
|
|
2006-02-21 17:55:38 +00:00
|
|
|
/* disable the following warnings
|
|
|
|
* C4100: The formal parameter is not referenced in the body of the function. The unreferenced parameter is ignored.
|
|
|
|
* C4200: Non standard extension C zero sized array
|
|
|
|
* C4204: nonstandard extension used : non-constant aggregate initializer
|
2006-02-24 16:58:40 +00:00
|
|
|
* C4706: assignment within conditional expression
|
2006-04-19 16:30:51 +00:00
|
|
|
* C4819: The file contains a character that cannot be represented in the current code page
|
2006-04-26 17:07:39 +00:00
|
|
|
* C4132: 'object' : const object should be initialized (fires innapropriately for prototyped forward declaration of cost var)
|
2007-02-13 06:08:28 +00:00
|
|
|
* C4510: default constructor could not be generated
|
|
|
|
* C4512: assignment operator could not be generated
|
|
|
|
* C4610: struct can never be instantiated - user defined constructor required
|
2006-02-21 17:55:38 +00:00
|
|
|
*/
|
2007-03-09 20:44:13 +00:00
|
|
|
#pragma warning(disable:4100 4200 4204 4706 4819 4132 4510 4512 4610 4996)
|
2006-02-20 00:23:25 +00:00
|
|
|
|
2005-12-29 17:25:28 +00:00
|
|
|
#if (_MSC_VER >= 1400) // VC8+
|
|
|
|
#ifndef _CRT_SECURE_NO_DEPRECATE
|
|
|
|
#define _CRT_SECURE_NO_DEPRECATE
|
|
|
|
#endif
|
|
|
|
#ifndef _CRT_NONSTDC_NO_DEPRECATE
|
|
|
|
#define _CRT_NONSTDC_NO_DEPRECATE
|
|
|
|
#endif
|
|
|
|
#endif // VC8+
|
|
|
|
|
2006-02-21 17:55:38 +00:00
|
|
|
#if _MSC_VER < 1300
|
|
|
|
#ifndef __FUNCTION__
|
|
|
|
#define __FUNCTION__ ""
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2006-09-12 03:14:52 +00:00
|
|
|
#undef inline
|
2006-09-02 18:33:29 +00:00
|
|
|
#define inline __inline
|
|
|
|
|
2006-02-21 17:55:38 +00:00
|
|
|
#ifndef uint32_t
|
|
|
|
typedef unsigned __int8 uint8_t;
|
|
|
|
typedef unsigned __int16 uint16_t;
|
|
|
|
typedef unsigned __int32 uint32_t;
|
|
|
|
typedef unsigned __int64 uint64_t;
|
|
|
|
typedef __int8 int8_t;
|
|
|
|
typedef __int16 int16_t;
|
|
|
|
typedef __int32 int32_t;
|
|
|
|
typedef __int64 int64_t;
|
|
|
|
typedef unsigned long in_addr_t;
|
|
|
|
#endif
|
2007-03-09 20:44:13 +00:00
|
|
|
typedef int pid_t;
|
|
|
|
typedef int uid_t;
|
|
|
|
typedef int gid_t;
|
2006-02-22 23:07:23 +00:00
|
|
|
#define PACKED
|
2006-03-01 06:25:56 +00:00
|
|
|
#include <io.h>
|
2007-03-09 20:44:13 +00:00
|
|
|
#define strcasecmp(s1, s2) stricmp(s1, s2)
|
|
|
|
#define strncasecmp(s1, s2, n) strnicmp(s1, s2, n)
|
2006-02-21 17:55:38 +00:00
|
|
|
#else
|
2006-02-22 21:04:53 +00:00
|
|
|
/* packed attribute */
|
|
|
|
#ifndef PACKED
|
2006-02-22 23:07:23 +00:00
|
|
|
#define PACKED __attribute__ ((__packed__))
|
2006-02-22 21:04:53 +00:00
|
|
|
#endif
|
2006-04-02 06:28:02 +00:00
|
|
|
#include <inttypes.h>
|
2006-02-21 17:55:38 +00:00
|
|
|
#include <unistd.h>
|
2007-03-09 20:44:13 +00:00
|
|
|
#include <arpa/inet.h>
|
2007-03-10 20:50:20 +00:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
2006-02-21 17:55:38 +00:00
|
|
|
#endif // _MSC_VER
|
|
|
|
|
2006-12-17 01:01:09 +00:00
|
|
|
#ifndef __LITTLE_ENDIAN
|
|
|
|
#define __LITTLE_ENDIAN 1234
|
|
|
|
#endif
|
|
|
|
#ifndef __BIG_ENDIAN
|
|
|
|
#define __BIG_ENDIAN 4321
|
|
|
|
#endif
|
|
|
|
#ifndef __BYTE_ORDER
|
|
|
|
#ifdef SWITCH_BYTE_ORDER
|
|
|
|
#define __BYTE_ORDER SWITCH_BYTE_ORDER
|
|
|
|
#else
|
|
|
|
#define __BYTE_ORDER __LITTLE_ENDIAN
|
|
|
|
#endif
|
|
|
|
#endif
|
2006-02-21 17:55:38 +00:00
|
|
|
|
2005-12-29 17:25:28 +00:00
|
|
|
#ifdef WIN32
|
2007-03-09 20:44:13 +00:00
|
|
|
|
2005-12-29 17:25:28 +00:00
|
|
|
#if defined(SWITCH_CORE_DECLARE_STATIC)
|
2005-12-29 19:14:05 +00:00
|
|
|
#define SWITCH_DECLARE(type) type __stdcall
|
|
|
|
#define SWITCH_DECLARE_NONSTD(type) type __cdecl
|
2005-12-29 17:25:28 +00:00
|
|
|
#define SWITCH_DECLARE_DATA
|
|
|
|
#elif defined(FREESWITCHCORE_EXPORTS)
|
2005-12-29 19:14:05 +00:00
|
|
|
#define SWITCH_DECLARE(type) __declspec(dllexport) type __stdcall
|
|
|
|
#define SWITCH_DECLARE_NONSTD(type) __declspec(dllexport) type __cdecl
|
|
|
|
#define SWITCH_DECLARE_DATA __declspec(dllexport)
|
2005-12-29 17:25:28 +00:00
|
|
|
#else
|
2005-12-29 19:14:05 +00:00
|
|
|
#define SWITCH_DECLARE(type) __declspec(dllimport) type __stdcall
|
|
|
|
#define SWITCH_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl
|
|
|
|
#define SWITCH_DECLARE_DATA __declspec(dllimport)
|
2005-12-29 17:25:28 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(SWITCH_MOD_DECLARE_STATIC)
|
2005-12-29 19:14:05 +00:00
|
|
|
#define SWITCH_MOD_DECLARE(type) type __cdecl
|
2005-12-29 17:25:28 +00:00
|
|
|
#elif defined(MOD_EXPORTS)
|
2005-12-29 19:14:05 +00:00
|
|
|
#define SWITCH_MOD_DECLARE(type) __declspec(dllexport) type __cdecl
|
2005-12-29 17:25:28 +00:00
|
|
|
#else
|
2005-12-29 19:14:05 +00:00
|
|
|
#define SWITCH_MOD_DECLARE(type) __declspec(dllimport) type __cdecl
|
2005-12-29 17:25:28 +00:00
|
|
|
#endif
|
2006-02-24 00:02:02 +00:00
|
|
|
#define SIGHUP SIGTERM
|
2007-02-17 06:55:43 +00:00
|
|
|
#ifndef S_IRUSR
|
|
|
|
#define S_IRUSR _S_IREAD
|
|
|
|
#endif
|
|
|
|
#ifndef S_IWUSR
|
|
|
|
#define S_IWUSR _S_IWRITE
|
|
|
|
#endif
|
2007-03-09 20:44:13 +00:00
|
|
|
#define SWITCH_THREAD_FUNC __stdcall
|
2005-12-29 17:25:28 +00:00
|
|
|
#else //not win32
|
|
|
|
#define SWITCH_DECLARE(type) type
|
|
|
|
#define SWITCH_DECLARE_NONSTD(type) type
|
|
|
|
#define SWITCH_MOD_DECLARE(type) type
|
|
|
|
#define SWITCH_DECLARE_DATA
|
2007-03-09 20:44:13 +00:00
|
|
|
#define SWITCH_THREAD_FUNC
|
2005-12-29 17:25:28 +00:00
|
|
|
#endif
|
|
|
|
|
2006-01-02 22:36:01 +00:00
|
|
|
#ifdef DOXYGEN
|
|
|
|
#define DoxyDefine(x) x
|
|
|
|
#else
|
|
|
|
#define DoxyDefine(x)
|
|
|
|
#endif
|
|
|
|
|
2007-02-13 03:17:19 +00:00
|
|
|
#if __GNUC__ >= 3
|
|
|
|
#define PRINTF_FUNCTION(fmtstr,vars) __attribute__((format(printf,fmtstr,vars)))
|
|
|
|
#else
|
|
|
|
#define PRINTF_FUNCTION(fmtstr,vars)
|
|
|
|
#endif
|
|
|
|
|
2007-03-09 20:44:13 +00:00
|
|
|
#ifdef SWITCH_INT32
|
|
|
|
typedef SWITCH_INT32 switch_int32_t;
|
|
|
|
#else
|
|
|
|
typedef int32_t switch_int32_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef SWITCH_SIZE_T
|
|
|
|
typedef SWITCH_SIZE_T switch_size_t;
|
|
|
|
#else
|
|
|
|
typedef uintptr_t switch_size_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef SWITCH_SSIZE_T
|
|
|
|
typedef SWITCH_SSIZE_T switch_ssize_t;
|
|
|
|
#else
|
|
|
|
typedef intptr_t switch_ssize_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
|
|
|
|
#ifdef WIN64
|
|
|
|
#define SWITCH_SSIZE_T_FMT "%I64d"
|
|
|
|
#define SWITCH_SIZE_T_FMT "%I64d"
|
|
|
|
#else
|
|
|
|
#define SWITCH_SSIZE_T_FMT "%d"
|
|
|
|
#define SWITCH_SIZE_T_FMT "%d"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SWITCH_INT64_T_FMT "%I64d"
|
|
|
|
#define SWITCH_UINT64_T_FMT "%I64u"
|
|
|
|
|
|
|
|
#else
|
|
|
|
#ifndef SWITCH_SSIZE_T_FMT
|
|
|
|
#define SWITCH_SSIZE_T_FMT (sizeof (switch_ssize_t) == sizeof (long) ? "%ld" : sizeof (switch_ssize_t) == sizeof (int) ? "%d" : "%lld")
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SWITCH_SIZE_T_FMT
|
|
|
|
#define SWITCH_SIZE_T_FMT (sizeof (switch_size_t) == sizeof (long) ? "%lu" : sizeof (switch_size_t) == sizeof (int) ? "%u" : "%llu")
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SWITCH_INT64_T_FMT
|
|
|
|
#define SWITCH_INT64_T_FMT (sizeof (long) == 8 ? "%ld" : "%lld")
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef SWITCH_UINT64_T_FMT
|
|
|
|
#define SWITCH_UINT64_T_FMT (sizeof (long) == 8 ? "%lu" : "%llu")
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SWITCH_TIME_T_FMT SWITCH_INT64_T_FMT
|
|
|
|
|
2006-09-07 15:15:39 +00:00
|
|
|
SWITCH_END_EXTERN_C
|
2005-12-29 17:25:28 +00:00
|
|
|
|
2007-03-09 20:44:13 +00:00
|
|
|
/* these includes must be outside the extern "C" block on windows or it will break compatibility with c++ modules*/
|
|
|
|
#ifdef WIN32
|
|
|
|
/* Has windows.h already been included? If so, our preferences don't matter,
|
|
|
|
* but we will still need the winsock things no matter what was included.
|
|
|
|
* If not, include a restricted set of windows headers to our tastes.
|
|
|
|
*/
|
|
|
|
#ifndef _WINDOWS_
|
|
|
|
#ifndef WIN32_LEAN_AND_MEAN
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
2005-12-29 17:25:28 +00:00
|
|
|
#endif
|
2007-03-09 20:44:13 +00:00
|
|
|
#ifndef _WIN32_WINNT
|
|
|
|
|
|
|
|
/* Restrict the server to a subset of Windows NT 4.0 header files by default
|
|
|
|
*/
|
|
|
|
#define _WIN32_WINNT 0x0400
|
|
|
|
#endif
|
|
|
|
#ifndef NOUSER
|
|
|
|
#define NOUSER
|
|
|
|
#endif
|
|
|
|
#ifndef NOMCX
|
|
|
|
#define NOMCX
|
|
|
|
#endif
|
|
|
|
#ifndef NOIME
|
|
|
|
#define NOIME
|
|
|
|
#endif
|
|
|
|
#include <windows.h>
|
|
|
|
/*
|
|
|
|
* Add a _very_few_ declarations missing from the restricted set of headers
|
|
|
|
* (If this list becomes extensive, re-enable the required headers above!)
|
|
|
|
* winsock headers were excluded by WIN32_LEAN_AND_MEAN, so include them now
|
|
|
|
*/
|
|
|
|
#define SW_HIDE 0
|
|
|
|
#ifndef _WIN32_WCE
|
|
|
|
#include <winsock2.h>
|
|
|
|
#include <mswsock.h>
|
|
|
|
#include <ws2tcpip.h>
|
|
|
|
#else
|
|
|
|
#include <winsock.h>
|
|
|
|
#endif
|
|
|
|
#endif /* !_WINDOWS_ */
|
|
|
|
#include <process.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef FALSE
|
|
|
|
#define FALSE 0
|
|
|
|
#endif
|
|
|
|
#ifndef TRUE
|
|
|
|
#define TRUE (!FALSE)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2006-11-27 22:30:48 +00:00
|
|
|
|
|
|
|
/* For Emacs:
|
|
|
|
* Local Variables:
|
|
|
|
* mode:c
|
2007-02-09 02:36:03 +00:00
|
|
|
* indent-tabs-mode:t
|
2006-11-27 22:30:48 +00:00
|
|
|
* tab-width:4
|
|
|
|
* c-basic-offset:4
|
|
|
|
* End:
|
|
|
|
* For VIM:
|
|
|
|
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
|
|
|
|
*/
|