mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-17 14:58:34 +00:00
update libks
This commit is contained in:
1 parent
238e228942
commit
9fd0b6bd2f
128 files changed
+41586
-2145
No files matched your search
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007-2014, Anthony Minessale II
|
||||
* Copyright (c) 2007-2015, Anthony Minessale II
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -34,33 +34,94 @@
|
||||
#ifndef _KS_PLATFORM_H_
|
||||
#define _KS_PLATFORM_H_
|
||||
|
||||
#include <stdarg.h>
|
||||
KS_BEGIN_EXTERN_C
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* defined(__cplusplus) */
|
||||
|
||||
#if !defined(_XOPEN_SOURCE) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__)
|
||||
#if !defined(_XOPEN_SOURCE) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__APPLE__)
|
||||
#define _XOPEN_SOURCE 600
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRINGS_H
|
||||
#define HAVE_STRINGS_H 1
|
||||
#endif
|
||||
#ifndef HAVE_SYS_SOCKET_H
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
#if defined(__linux__) && !defined(_DEFAULT_SOURCE)
|
||||
#define _DEFAULT_SOURCE 1
|
||||
#endif
|
||||
|
||||
#ifndef __WINDOWS__
|
||||
#if defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32)
|
||||
#if !defined(__WINDOWS__) && (defined(WIN32) || defined(WIN64) || defined(_MSC_VER) || defined(_WIN32))
|
||||
#define __WINDOWS__
|
||||
#endif
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#if UINTPTR_MAX == 0xffffffffffffffff
|
||||
#define KS_64BIT 1
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <ctype.h>
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <sys/select.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <sys/signal.h>
|
||||
#include <unistd.h>
|
||||
#include <strings.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma comment(lib, "Ws2_32.lib")
|
||||
|
||||
#include <io.h>
|
||||
/*#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <Synchapi.h>
|
||||
*/
|
||||
#ifndef open
|
||||
#define open _open
|
||||
#endif
|
||||
|
||||
#ifndef close
|
||||
#define close _close
|
||||
#endif
|
||||
|
||||
#ifndef read
|
||||
#define read _read
|
||||
#endif
|
||||
|
||||
#ifndef write
|
||||
#define write _write
|
||||
#endif
|
||||
|
||||
#ifndef __inline__
|
||||
#define __inline__ __inline
|
||||
#endif
|
||||
|
||||
#ifndef strdup
|
||||
#define strdup _strdup
|
||||
#endif
|
||||
|
||||
#if (_MSC_VER >= 1400) /* VC8+ */
|
||||
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
@@ -69,67 +130,62 @@ extern "C" {
|
||||
#define _CRT_NONSTDC_NO_DEPRECATE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef strcasecmp
|
||||
#define strcasecmp(s1, s2) _stricmp(s1, s2)
|
||||
#endif
|
||||
|
||||
#ifndef strncasecmp
|
||||
#define strncasecmp(s1, s2, n) _strnicmp(s1, s2, n)
|
||||
#endif
|
||||
|
||||
#if (_MSC_VER < 1900) /* VC 2015 */
|
||||
#ifndef snprintf
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef S_IRUSR
|
||||
#define S_IRUSR _S_IREAD
|
||||
#endif
|
||||
|
||||
#ifndef S_IWUSR
|
||||
#define S_IWUSR _S_IWRITE
|
||||
#endif
|
||||
#undef HAVE_STRINGS_H
|
||||
#undef HAVE_SYS_SOCKET_H
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#if (_MSC_VER >= 1400) // VC8+
|
||||
#define ks_assert(expr) assert(expr);__analysis_assume( expr )
|
||||
#endif
|
||||
|
||||
#include <time.h>
|
||||
#ifndef WIN32
|
||||
#include <sys/time.h>
|
||||
#ifndef ks_assert
|
||||
#define ks_assert(_x) assert(_x)
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifndef WIN32
|
||||
#include <sys/types.h>
|
||||
#include <sys/select.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <sys/signal.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
#ifdef __WINDOWS__
|
||||
typedef SOCKET ks_socket_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef __int8 int8_t;
|
||||
typedef intptr_t ks_ssize_t;
|
||||
typedef int ks_filehandle_t;
|
||||
|
||||
#ifdef HAVE_STRINGS_H
|
||||
#include <strings.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
typedef SOCKET ks_socket_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef __int8 int8_t;
|
||||
typedef intptr_t ks_ssize_t;
|
||||
typedef int ks_filehandle_t;
|
||||
#define KS_SOCK_INVALID INVALID_SOCKET
|
||||
#define strerror_r(num, buf, size) strerror_s(buf, size, num)
|
||||
#else
|
||||
#define KS_SOCK_INVALID -1
|
||||
typedef int ks_socket_t;
|
||||
typedef ssize_t ks_ssize_t;
|
||||
typedef int ks_filehandle_t;
|
||||
#endif
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
#if defined(KS_DECLARE_STATIC)
|
||||
#define KS_DECLARE(type) type __stdcall
|
||||
#define KS_DECLARE_NONSTD(type) type __cdecl
|
||||
@@ -143,30 +199,68 @@ typedef int ks_filehandle_t;
|
||||
#define KS_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl
|
||||
#define KS_DECLARE_DATA __declspec(dllimport)
|
||||
#endif
|
||||
#else // !WIN32
|
||||
#else // !WIN32
|
||||
#if (defined(__GNUC__) || defined(__SUNPRO_CC) || defined (__SUNPRO_C)) && defined(KS_API_VISIBILITY)
|
||||
#define KS_DECLARE(type) __attribute__((visibility("default"))) type
|
||||
#define KS_DECLARE_NONSTD(type) __attribute__((visibility("default"))) type
|
||||
#define KS_DECLARE_DATA __attribute__((visibility("default")))
|
||||
#else
|
||||
#define KS_DECLARE(type) type
|
||||
#define KS_DECLARE_NONSTD(type) type
|
||||
#define KS_DECLARE_DATA
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#define KS_SOCK_INVALID -1
|
||||
typedef int ks_socket_t;
|
||||
typedef ssize_t ks_ssize_t;
|
||||
typedef int ks_filehandle_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* malloc or DIE macros */
|
||||
#ifdef NDEBUG
|
||||
#define ks_malloc(ptr, len) (void)( (!!(ptr = malloc(len))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%d", __FILE__, __LINE__),abort(), 0), ptr )
|
||||
#define ks_zmalloc(ptr, len) (void)( (!!(ptr = calloc(1, (len)))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%d", __FILE__, __LINE__),abort(), 0), ptr)
|
||||
#if (_MSC_VER >= 1500) // VC9+
|
||||
#define ks_strdup(ptr, s) (void)( (!!(ptr = _strdup(s))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%d", __FILE__, __LINE__),abort(), 0), ptr)
|
||||
#else
|
||||
#define ks_strdup(ptr, s) (void)( (!!(ptr = strdup(s))) || (fprintf(stderr,"ABORT! Malloc failure at: %s:%d", __FILE__, __LINE__),abort(), 0), ptr)
|
||||
#endif
|
||||
#else
|
||||
#if (_MSC_VER >= 1500) // VC9+
|
||||
#define ks_malloc(ptr, len) (void)(assert(((ptr) = malloc((len)))),ptr);__analysis_assume( ptr )
|
||||
#define ks_zmalloc(ptr, len) (void)(assert((ptr = calloc(1, (len)))),ptr);__analysis_assume( ptr )
|
||||
#define ks_strdup(ptr, s) (void)(assert(((ptr) = _strdup(s))),ptr);__analysis_assume( ptr )
|
||||
#else
|
||||
#define ks_malloc(ptr, len) (void)(assert(((ptr) = malloc((len)))),ptr)
|
||||
#define ks_zmalloc(ptr, len) (void)(assert((ptr = calloc(1, (len)))),ptr)
|
||||
#define ks_strdup(ptr, s) (void)(assert(((ptr) = strdup((s)))),ptr)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __ATTR_SAL
|
||||
/* used for msvc code analysis */
|
||||
/* http://msdn2.microsoft.com/en-us/library/ms235402.aspx */
|
||||
#define _In_
|
||||
#define _In_z_
|
||||
#define _In_opt_z_
|
||||
#define _In_opt_
|
||||
#define _Printf_format_string_
|
||||
#define _Ret_opt_z_
|
||||
#define _Ret_z_
|
||||
#define _Out_opt_
|
||||
#define _Out_
|
||||
#define _Check_return_
|
||||
#define _Inout_
|
||||
#define _Inout_opt_
|
||||
#define _In_bytecount_(x)
|
||||
#define _Out_opt_bytecapcount_(x)
|
||||
#define _Out_bytecapcount_(x)
|
||||
#define _Ret_
|
||||
#define _Post_z_
|
||||
#define _Out_cap_(x)
|
||||
#define _Out_z_cap_(x)
|
||||
#define _Out_ptrdiff_cap_(x)
|
||||
#define _Out_opt_ptrdiff_cap_(x)
|
||||
#define _Post_count_(x)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* defined(__cplusplus) */
|
||||
#endif /* defined(_KS_PLATFORM_H_) */
|
||||
|
||||
KS_END_EXTERN_C
|
||||
#endif /* defined(_KS_PLATFORM_H_) */
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
|
||||
Reference in new issue
Block a user