⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sys.h

📁 OTP是开放电信平台的简称
💻 H
📖 第 1 页 / 共 3 页
字号:
/* ``The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved via the world wide web at http://www.erlang.org/. *  * 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 Initial Developer of the Original Code is Ericsson Utvecklings AB. * Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings * AB. All Rights Reserved.'' *  *     $Id$ */#ifndef __SYS_H__#define __SYS_H__#if defined(VALGRIND) && !defined(NO_FPE_SIGNALS)#  define NO_FPE_SIGNALS#endif/* Never use elib-malloc when purify-memory-tracing */#if defined(PURIFY)#undef ENABLE_ELIB_MALLOC#undef ELIB_HEAP_SBRK#undef ELIB_ALLOC_IS_CLIB#endif/* xxxP __VXWORKS__ */#ifdef VXWORKS#include <vxWorks.h>#endif#ifdef DISABLE_CHILD_WAITER_THREAD#undef ENABLE_CHILD_WAITER_THREAD#endif#if defined(ERTS_SMP) && !defined(DISABLE_CHILD_WAITER_THREAD)#undef ENABLE_CHILD_WAITER_THREAD#define ENABLE_CHILD_WAITER_THREAD 1#endif/* The ERTS_TIMER_TREAD #define must be visible to the   erl_${OS}_sys.h #include files: it controls whether   certain optional facilities should be defined or not. */#if defined(ERTS_SMP) && 0#define ERTS_TIMER_THREAD#endif#ifdef ERTS_SMP /* Use port tasks by default on on smp emu */#define ERTS_USE_PORT_TASKS #endif#ifdef ERTS_DONT_USE_PORT_TASKS#undef ERTS_USE_PORT_TASKS#endif#if defined(ERTS_SMP_USE_IO_THREAD) && !defined(ERTS_SMP)#undef ERTS_SMP_USE_IO_THREAD#endif#if defined(ERTS_SMP_USE_IO_THREAD) && defined(ERTS_USE_PORT_TASKS)#error "Cannot combine I/O thread with port tasks"#endif#if defined (__WIN32__)#  include "erl_win_sys.h"#elif defined (VXWORKS) #  include "erl_vxworks_sys.h"#elif defined (_OSE_) #  include "erl_ose_sys.h"#else #  include "erl_unix_sys.h"#ifndef UNIX#  define UNIX 1#endif#endif/* * To allow building of Universal Binaries for Mac OS X, * we must not depend on the endian detected by the configure script. */#if defined(__APPLE__)#  if defined(__BIG_ENDIAN__) && !defined(WORDS_BIGENDIAN)#    define WORDS_BIGENDIAN 1#  elif !defined(__BIG_ENDIAN__) && defined(WORDS_BIGENDIAN)#    undef WORDS_BIGENDIAN#  endif#endif/* * Make sure that ENOTSUP is defined. */#ifndef ENOTSUP#  ifdef EOPNOTSUPP#    define ENOTSUP EOPNOTSUPP#else#    define ENOTSUP -1738659#  endif#endif#ifdef ERTS_INLINE#  ifndef ERTS_CAN_INLINE#    define ERTS_CAN_INLINE 1#  endif#else#  if defined(__GNUC__)#    define ERTS_CAN_INLINE 1#    define ERTS_INLINE __inline__#  elif defined(__WIN32__)#    define ERTS_CAN_INLINE 1#    define ERTS_INLINE __inline#  else#    define ERTS_CAN_INLINE 0#    define ERTS_INLINE#  endif#endif#if defined(DEBUG) || defined(ERTS_ENABLE_LOCK_CHECK)#  undef ERTS_CAN_INLINE#  define ERTS_CAN_INLINE 0#  undef ERTS_INLINE#  define ERTS_INLINE#endif#if ERTS_CAN_INLINE#define ERTS_GLB_INLINE static ERTS_INLINE#else#define ERTS_GLB_INLINE#endif#if ERTS_CAN_INLINE || defined(ERTS_DO_INCL_GLB_INLINE_FUNC_DEF) #  define ERTS_GLB_INLINE_INCL_FUNC_DEF 1#else#  define ERTS_GLB_INLINE_INCL_FUNC_DEF 0#endif#ifndef ERTS_EXIT_AFTER_DUMP#  define ERTS_EXIT_AFTER_DUMP exit#endif#ifdef DEBUG#  define ASSERT(e) \  if (e) { \     ; \  } else { \     erl_assert_error(#e, __FILE__, __LINE__); \  }#  define ASSERT_EXPR(e) \    ((void) ((e) ? 1 : (erl_assert_error(#e, __FILE__, __LINE__), 0)))void erl_assert_error(char* expr, char* file, int line);#else#  define ASSERT(e)#  define ASSERT_EXPR(e) ((void) 1)#endif/* * Microsoft C/C++: We certainly want to use stdarg.h and prototypes. * But MSC doesn't define __STDC__, unless we compile with the -Za * flag (strict ANSI C, no Microsoft extension).  Compiling with -Za * doesn't work: some Microsoft headers fail to compile... * * Solution: Test if __STDC__ or _MSC_VER is defined. * * Note: Simply defining __STDC__ doesn't work, as some Microsoft * headers will fail to compile! */#include <stdarg.h>#if defined(__STDC__) || defined(_MSC_VER)#  define EXTERN_FUNCTION(t, f, x)  extern t f x#  define FUNCTION(t, f, x) t f x#  define _DOTS_ ...#  define _VOID_      void#elif defined(__cplusplus)#  define EXTERN_FUNCTION(f, x) extern "C" { f x }#  define FUNCTION(t, f, x) t f x#  define _DOTS_ ...#  define _VOID_    void#else#  define EXTERN_FUNCTION(t, f, x) extern t f (/*x*/)#  define FUNCTION(t, f, x) t f (/*x*/)#  define _DOTS_#  define _VOID_#endif/* This isn't sys-dependent, but putting it here benefits sys.c and drivers   - allow use of 'const' regardless of compiler */#if !defined(__STDC__) && !defined(_MSC_VER)#  define const#endif#ifdef VXWORKS/* Replace VxWorks' printf with a real one that does fprintf(stdout, ...) */EXTERN_FUNCTION(int, real_printf, (const char *fmt, ...));#  define printf real_printf#endif#if __GNUC__#  define __noreturn __attribute__((noreturn))#  undef __deprecated#  if __GNUC__ >= 3#    define __deprecated __attribute__((deprecated))#  else#    define __deprecated#  endif#else#  define __noreturn#  define __deprecated#endif/*** Data types:**** Eterm: A tagged erlang term (possibly 64 bits)** UInt:  An unsigned integer exactly as large as an Eterm.** SInt:  A signed integer exactly as large as an eterm and therefor large**        enough to hold the return value of the signed_val() macro.** Uint32: An unsigned integer of 32 bits exactly** Sint32: A signed integer of 32 bits exactly** Uint16: An unsigned integer of 16 bits exactly** Sint16: A signed integer of 16 bits exactly.*/#if SIZEOF_VOID_P == 8#undef  ARCH_32#define ARCH_64#elif SIZEOF_VOID_P == 4#define ARCH_32#undef  ARCH_64#else#error Neither 32 nor 64 bit architecture#endif#if SIZEOF_VOID_P != SIZEOF_SIZE_T#error sizeof(void*) != sizeof(size_t)#endif#if SIZEOF_VOID_P == SIZEOF_LONGtypedef unsigned long Eterm;typedef unsigned long Uint;typedef long          Sint;#elif SIZEOF_VOID_P == SIZEOF_INTtypedef unsigned int Eterm;typedef unsigned int Uint;typedef int          Sint;#else#error Found no appropriate type to use for 'Eterm', 'Uint' and 'Sint'#endif#ifndef HAVE_INT64#if SIZEOF_LONG == 8#define HAVE_INT64 1typedef unsigned long Uint64;typedef long          Sint64;#elif SIZEOF_LONG_LONG == 8#define HAVE_INT64 1typedef unsigned long long Uint64;typedef long long          Sint64;#else#define HAVE_INT64 0#endif#endif#if SIZEOF_LONG == 4typedef unsigned long Uint32;typedef long          Sint32;#elif SIZEOF_INT == 4typedef unsigned int Uint32;typedef int          Sint32;#else#error Found no appropriate type to use for 'Uint32' and 'Sint32'#endif#if SIZEOF_INT == 2typedef unsigned int Uint16;typedef int          Sint16;#elif SIZEOF_SHORT == 2typedef unsigned short Uint16;typedef short          Sint16;#else#error Found no appropriate type to use for 'Uint16' and 'Sint16'#endif#if CHAR_BIT == 8typedef unsigned char byte;#else#error Found no appropriate type to use for 'byte'#endif#if defined(ARCH_64) && !HAVE_INT64#error 64-bit architecture, but no appropriate type to use for Uint64 and Sint64 found #endif#include "erl_lock_check.h"#include "erl_smp.h"#ifdef UNIX#ifdef ERTS_WANT_BREAK_HANDLING#ifdef ERTS_SMPextern erts_smp_atomic_t erts_break_requested;#define ERTS_BREAK_REQUESTED ((int) erts_smp_atomic_read(&erts_break_requested))#elseextern volatile int erts_break_requested;#define ERTS_BREAK_REQUESTED erts_break_requested#endifvoid erts_do_break_handling(void);#endif#ifdef ERTS_WANT_GOT_SIGUSR1#ifdef ERTS_SMPextern erts_smp_atomic_t erts_got_sigusr1;#define ERTS_GOT_SIGUSR1 ((int) erts_smp_atomic_read(&erts_got_sigusr1))#elseextern volatile int erts_got_sigusr1;#define ERTS_GOT_SIGUSR1 erts_got_sigusr1#endif#endif#endif /* UNIX */#ifdef ERTS_SMPextern erts_smp_atomic_t erts_writing_erl_crash_dump;#define ERTS_IS_CRASH_DUMPING \  ((int) erts_smp_atomic_read(&erts_writing_erl_crash_dump))#elseextern volatile int erts_writing_erl_crash_dump;#define ERTS_IS_CRASH_DUMPING erts_writing_erl_crash_dump#endif/* Deal with memcpy() vs bcopy() etc. We want to use the mem*() functions,   but be able to fall back on bcopy() etc on systems that don't have   mem*(), but this doesn't work to well with memset()/bzero() - thus the   memzero() macro.*//* xxxP */#if defined(USE_BCOPY)#  define memcpy(a, b, c) bcopy((b), (a), (c))#  define memcmp(a, b, c) bcmp((a), (b), (c))#  define memzero(buf, len) bzero((buf), (len))#else#  define memzero(buf, len) memset((buf), '\0', (len))#endif/* Stuff that is useful for port programs, drivers, etc */#ifdef ISC32			/* Too much for the Makefile... */#  define signal	sigset#  define NO_ASINH#  define NO_ACOSH#  define NO_ATANH#  define NO_FTRUNCATE#  define SIG_SIGHOLD#  define _POSIX_SOURCE #  define _XOPEN_SOURCE#endif#ifdef QNX			/* Too much for the Makefile... */#  define SYS_SELECT_H#  define NO_ERF#  define NO_ERFC/* This definition doesn't take NaN into account, but matherr() gets those */#  define finite(x) (fabs(x) != HUGE_VAL)#  define USE_MATHERR#  define HAVE_FINITE#endif#ifdef WANT_NONBLOCKING	    /* must define this to pull in fcntl.h/ioctl.h *//* This is really a mess... We used to use fcntl O_NDELAY, but that seems   to only work on SunOS 4 - in particular, on SysV-based systems   (including Solaris 2), it does set non-blocking mode, but causes   read() to return 0!!  fcntl O_NONBLOCK is specified by POSIX, and   seems to work on most systems, with the notable exception of AIX,   where the old ioctl FIONBIO is the *only* one that will set a *socket*   in non-blocking mode - and ioctl FIONBIO on AIX *doesn't* work for   pipes or ttys (O_NONBLOCK does)!!! For now, we'll use FIONBIO for AIX. */# ifdef _OSE_static const int zero_value = 0, one_value = 1;#      define SET_BLOCKING(fd)	        ioctl((fd), FIONBIO, (char*)&zero_value)#      define SET_NONBLOCKING(fd)	ioctl((fd), FIONBIO, (char*)&one_value)#      define ERRNO_BLOCK EWOULDBLOCK# else

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -