• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

ink_defs.h

Go to the documentation of this file.
00001 /** @file
00002 
00003   Some small general interest definitions
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 #ifndef _ink_defs_h
00025 #define _ink_defs_h
00026 
00027 
00028 #include "ink_config.h"
00029 #include <stddef.h>
00030 
00031 #ifdef HAVE_STDINT_H
00032 # include <stdint.h>
00033 #else
00034 // TODO: Add "standard" int types?
00035 #endif
00036 
00037 #ifdef HAVE_INTTYPES_H
00038 # include <inttypes.h>
00039 #else
00040 // TODO: add PRI*64 stuff?
00041 #endif
00042 
00043 #ifndef INT64_MIN
00044 #define INT64_MAX (9223372036854775807LL)
00045 #define INT64_MIN (-INT64_MAX -1LL)
00046 #define INT32_MAX (2147483647)
00047 #define INT32_MIN (-2147483647-1)
00048 #endif
00049 
00050 #define POSIX_THREAD
00051 #define POSIX_THREAD_10031c
00052 
00053 #ifndef ETIME
00054 #ifdef ETIMEDOUT
00055 #define ETIME ETIMEDOUT
00056 #endif
00057 #endif
00058 
00059 #ifndef ENOTSUP
00060 #ifdef EOPNOTSUPP
00061 #define ENOTSUP EOPNOTSUPP
00062 #endif
00063 #endif
00064 
00065 #if defined(darwin)
00066 #define RENTRENT_GETHOSTBYNAME
00067 #define RENTRENT_GETHOSTBYADDR
00068 #endif
00069 
00070 #define NUL '\0'
00071 
00072 // Need to use this to avoid problems when calling variadic functions
00073 // with many arguments. In such cases, a raw '0' or NULL can be
00074 // interpreted as 32 bits
00075 #define NULL_PTR static_cast<void*>(0)
00076 
00077 // Determine the element count for an array.
00078 #ifdef __cplusplus
00079 template<typename T, unsigned N>
00080 static inline unsigned
00081 countof(const T (&)[N]) {
00082   return N;
00083 }
00084 #else
00085 #  define countof(x) ((unsigned)(sizeof(x)/sizeof((x)[0])))
00086 #endif
00087 
00088 #define SOCKOPT_ON ((char*)&on)
00089 #define SOCKOPT_OFF ((char*)&off)
00090 
00091 #ifndef ABS
00092 #define ABS(x) (((x) < 0) ? ( - (x)) : (x))
00093 #endif
00094 
00095 #ifndef MAX
00096 #define MAX(x,y) (((x) >= (y)) ? (x) : (y))
00097 #endif
00098 
00099 #ifndef MIN
00100 #define MIN(x,y) (((x) <= (y)) ? (x) : (y))
00101 #endif
00102 
00103 #define ATS_UNUSED __attribute__ ((unused))
00104 #define ATS_WARN_IF_UNUSED __attribute__ ((warn_unused_result))
00105 #define ATS_UNUSED_RETURN(x)    if (x) {}
00106 
00107 #ifndef likely
00108 #define likely(x)       __builtin_expect (!!(x), 1)
00109 #endif
00110 #ifndef unlikely
00111 #define unlikely(x)     __builtin_expect (!!(x), 0)
00112 #endif
00113 
00114 
00115 #if TS_USE_HWLOC
00116 #  include <hwloc.h>
00117 #endif
00118 
00119 #ifndef ROUNDUP
00120 #define ROUNDUP(x, y) ((((x)+((y)-1))/(y))*(y))
00121 #endif
00122 
00123 /* Types
00124 */
00125 typedef void *(*VPVP_PFN) (void *);
00126 typedef void (*VVP_PFN) (void *);
00127 typedef void (*VV_PFN) (void);
00128 typedef void (*VI_PFN) (int);
00129 
00130 /* Variables
00131 */
00132 extern int debug_level;
00133 extern int off;
00134 extern int on;
00135 
00136 /* Functions
00137 */
00138 int ink_sys_name_release(char *name, int namelen, char *release, int releaselen);
00139 int ink_number_of_processors();
00140 
00141 #if TS_USE_HWLOC
00142 // Get the hardware topology
00143 hwloc_topology_t ink_get_topology();
00144 #endif
00145 
00146 /** Constants.
00147  */
00148 #ifdef __cplusplus
00149 namespace ts {
00150   static const int NO_FD = -1; ///< No or invalid file descriptor.
00151 }
00152 #endif
00153 
00154 #endif /*__ink_defs_h*/

Generated by  doxygen 1.7.1