2  * Copyright (c) 2008-2013 Apple Inc. All rights reserved. 
   4  * @APPLE_APACHE_LICENSE_HEADER_START@ 
   6  * Licensed under the Apache License, Version 2.0 (the "License"); 
   7  * you may not use this file except in compliance with the License. 
   8  * You may obtain a copy of the License at 
  10  *     http://www.apache.org/licenses/LICENSE-2.0 
  12  * Unless required by applicable law or agreed to in writing, software 
  13  * distributed under the License is distributed on an "AS IS" BASIS, 
  14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
  15  * See the License for the specific language governing permissions and 
  16  * limitations under the License. 
  18  * @APPLE_APACHE_LICENSE_HEADER_END@ 
  22  * IMPORTANT: This header file describes INTERNAL interfaces to libdispatch 
  23  * which are subject to change in future releases of Mac OS X. Any applications 
  24  * relying on these interfaces WILL break. 
  27 #ifndef __DISPATCH_SEMAPHORE_INTERNAL__ 
  28 #define __DISPATCH_SEMAPHORE_INTERNAL__ 
  30 struct dispatch_queue_s
; 
  33 #define DISPATCH_OS_SEMA_FIELD(base)    semaphore_t base##_port 
  35 #define DISPATCH_OS_SEMA_FIELD(base)    sem_t base##_sem 
  37 #define DISPATCH_OS_SEMA_FIELD(base)    HANDLE base##_handle 
  39 #error "No supported semaphore type" 
  42 #define DISPATCH_SEMAPHORE_HEADER(cls, ns) \ 
  43         DISPATCH_OBJECT_HEADER(cls); \ 
  44         long volatile ns##_value; \ 
  45         DISPATCH_OS_SEMA_FIELD(ns) 
  47 struct dispatch_semaphore_header_s 
{ 
  48         DISPATCH_SEMAPHORE_HEADER(semaphore
, dsema
); 
  51 DISPATCH_CLASS_DECL(semaphore
); 
  52 struct dispatch_semaphore_s 
{ 
  53         DISPATCH_SEMAPHORE_HEADER(semaphore
, dsema
); 
  57 DISPATCH_CLASS_DECL(group
); 
  58 struct dispatch_group_s 
{ 
  59         DISPATCH_SEMAPHORE_HEADER(group
, dg
); 
  60         int volatile dg_waiters
; 
  61         struct dispatch_continuation_s 
*volatile dg_notify_head
; 
  62         struct dispatch_continuation_s 
*volatile dg_notify_tail
; 
  66         struct dispatch_semaphore_header_s 
*_dsema_hdr
; 
  67         struct dispatch_semaphore_s 
*_dsema
; 
  68         struct dispatch_group_s 
*_dg
; 
  70         dispatch_semaphore_t _objc_dsema
; 
  71         dispatch_group_t _objc_dg
; 
  73 } dispatch_semaphore_class_t 
__attribute__((__transparent_union__
)); 
  75 dispatch_group_t 
_dispatch_group_create_and_enter(void); 
  76 void _dispatch_group_dispose(dispatch_object_t dou
); 
  77 size_t _dispatch_group_debug(dispatch_object_t dou
, char *buf
, 
  80 void _dispatch_semaphore_dispose(dispatch_object_t dou
); 
  81 size_t _dispatch_semaphore_debug(dispatch_object_t dou
, char *buf
,