libXDispatch 0.4
include/libdispatch/base.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008-2009 Apple Inc. All rights reserved.
00003  *
00004  * @APPLE_APACHE_LICENSE_HEADER_START@
00005  * 
00006  * Licensed under the Apache License, Version 2.0 (the "License");
00007  * you may not use this file except in compliance with the License.
00008  * You may obtain a copy of the License at
00009  * 
00010  *     http://www.apache.org/licenses/LICENSE-2.0
00011  * 
00012  * Unless required by applicable law or agreed to in writing, software
00013  * distributed under the License is distributed on an "AS IS" BASIS,
00014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  * See the License for the specific language governing permissions and
00016  * limitations under the License.
00017  * 
00018  * @APPLE_APACHE_LICENSE_HEADER_END@
00019  */
00020 
00021 #ifndef __DISPATCH_BASE__
00022 #define __DISPATCH_BASE__
00023 
00024 #ifndef __DISPATCH_INDIRECT__
00025 #error "Please #include <dispatch/dispatch.h> instead of this file directly."
00026 #endif
00027 
00028 #if defined(__cplusplus) && !defined(_MSC_VER)
00029 /*
00030  * Dispatch objects are NOT C++ objects. Nevertheless, we can at least keep C++
00031  * aware of type compatibility.
00032  */
00033 typedef struct dispatch_object_s {
00034 private:
00035        dispatch_object_s();
00036        ~dispatch_object_s();
00037        dispatch_object_s(const dispatch_object_s &);
00038        void operator=(const dispatch_object_s &);
00039 } *dispatch_object_t;
00040 #else
00041 # ifdef __GNUC__
00042 typedef union {
00043     struct dispatch_object_s *_do;
00044     struct dispatch_continuation_s *_dc;
00045     struct dispatch_queue_s *_dq;
00046     struct dispatch_queue_attr_s *_dqa;
00047     struct dispatch_group_s *_dg;
00048     struct dispatch_source_s *_ds;
00049     struct dispatch_source_attr_s *_dsa;
00050     struct dispatch_semaphore_s *_dsema;
00051 } dispatch_object_t __attribute__((transparent_union));
00052 # else /* __GNUC__ */
00053 // this is really really ugly but
00054 // there is no transparent union in MSVC
00055 struct dispatch_object_s;
00056 typedef void* dispatch_object_t;
00057 #endif /* __GNUC__ */
00058 #endif
00059 
00060 typedef void (*dispatch_function_t)(void *);
00061 
00062 #if defined(__cplusplus) && !defined(_MSC_VER)
00063 #define DISPATCH_DECL(name) typedef struct name##_s : public dispatch_object_s {} *name##_t
00064 #else
00065 
00066 #define DISPATCH_DECL(name) typedef struct name##_s *name##_t
00067 #endif
00068 
00069 #ifdef __GNUC__
00070 # ifndef DISPATCH_NORETURN
00071 #  define DISPATCH_NORETURN __attribute__((__noreturn__))
00072 # endif
00073 # define DISPATCH_NOTHROW __attribute__((__nothrow__))
00074 # define DISPATCH_NONNULL1 __attribute__((__nonnull__(1)))
00075 # define DISPATCH_NONNULL2 __attribute__((__nonnull__(2)))
00076 # define DISPATCH_NONNULL3 __attribute__((__nonnull__(3)))
00077 # define DISPATCH_NONNULL4 __attribute__((__nonnull__(4)))
00078 # define DISPATCH_NONNULL5 __attribute__((__nonnull__(5)))
00079 # define DISPATCH_NONNULL6 __attribute__((__nonnull__(6)))
00080 # define DISPATCH_NONNULL7 __attribute__((__nonnull__(7)))
00081 # if __clang__
00082 // rdar://problem/6857843
00083 #  define DISPATCH_NONNULL_ALL
00084 # else
00085 #  define DISPATCH_NONNULL_ALL __attribute__((__nonnull__))
00086 # endif
00087 # define DISPATCH_SENTINEL __attribute__((__sentinel__))
00088 # define DISPATCH_PURE __attribute__((__pure__))
00089 # define DISPATCH_WARN_RESULT __attribute__((__warn_unused_result__))
00090 # define DISPATCH_MALLOC __attribute__((__malloc__))
00091 # define DISPATCH_FORMAT(...) __attribute__((__format__(__VA_ARGS__)))
00092 #else
00093 
00094 # define DISPATCH_NORETURN
00095 
00096 # define DISPATCH_NOTHROW
00097 
00098 # define DISPATCH_NONNULL1
00099 
00100 # define DISPATCH_NONNULL2
00101 
00102 # define DISPATCH_NONNULL3
00103 
00104 # define DISPATCH_NONNULL4
00105 
00106 # define DISPATCH_NONNULL5
00107 
00108 # define DISPATCH_NONNULL6
00109 
00110 # define DISPATCH_NONNULL7
00111 
00112 # define DISPATCH_NONNULL_ALL
00113 
00114 # define DISPATCH_SENTINEL
00115 
00116 # define DISPATCH_PURE
00117 
00118 # define DISPATCH_WARN_RESULT
00119 
00120 # define DISPATCH_MALLOC
00121 
00122 # define DISPATCH_FORMAT(...)
00123 #endif
00124 
00125 #ifndef DISPATCH_EXPORT
00126 # ifdef _WIN32
00127 #  ifdef DISPATCH_MAKEDLL
00128 #   define DISPATCH_EXPORT __declspec(dllexport)
00129 #  else
00130 #   define DISPATCH_EXPORT __declspec(dllimport)
00131 #  endif
00132 # else
00133 #  define DISPATCH_EXPORT __attribute__((visibility("default")))
00134 # endif
00135 #endif
00136 
00137 #ifndef DISPATCH_EXTERN
00138 # ifdef _WIN32
00139 #  define DISPATCH_EXTERN
00140 # else
00141 #  define DISPATCH_EXTERN extern
00142 # endif
00143 #endif
00144 
00145 #ifndef DISPATCH_PTR
00146 # ifdef _WIN32
00147 #  define DISPATCH_PTR *
00148 # else
00149 #  define DISPATCH_PTR
00150 # endif
00151 #endif
00152 
00153 #ifndef __OSX_AVAILABLE_STARTING
00154 # define __OSX_AVAILABLE_STARTING(...)
00155 #endif
00156 
00157 #endif
00158 

Generated on Wed Feb 22 2012 19:51:17 for libXDispatch by Doxygen 1.7.4
Content © 2011-2012 MLBA (about | privacy) – Design © 2010-2012 Emzeat. All Rights reserved.