1/* 2 * Copyright (c) 2005-2008 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * The contents of this file constitute Original Code as defined in and 7 * are subject to the Apple Public Source License Version 1.1 (the 8 * "License"). You may not use this file except in compliance with the 9 * License. Please obtain a copy of the License at 10 * http://www.apple.com/publicsource and read it before using this file. 11 * 12 * This Original Code and all software distributed under the License are 13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER 14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the 17 * License for the specific language governing rights and limitations 18 * under the License. 19 * 20 * @APPLE_LICENSE_HEADER_END@ 21 */ 22 23#ifndef _DARWIN_SHIM_H 24#define _DARWIN_SHIM_H 25 26#include <stdint.h> 27#include <sys/types.h> 28#include <sys/time.h> /* In lieu of Solaris <sys/synch.h> */ 29 30#undef NULL 31#define NULL (0) /* quiets many warnings */ 32 33typedef uint8_t uchar_t; 34typedef uint16_t ushort_t; 35typedef uint32_t uint_t; 36typedef unsigned long ulong_t; 37typedef uint64_t u_longlong_t; 38typedef int64_t longlong_t; 39typedef int64_t off64_t; 40 41typedef struct timespec timestruc_t; /* definition per SVr4 */ 42 43typedef int32_t time32_t; 44typedef struct timespec32 { 45 time32_t tv_sec; /* seconds */ 46 int32_t tv_nsec; /* and nanoseconds */ 47} timespec32_t; 48typedef struct timespec32 timestruc32_t; 49 50typedef int64_t hrtime_t; 51hrtime_t gethrtime(void); 52 53typedef uint32_t projid_t; 54typedef uint32_t taskid_t; 55typedef uint32_t zoneid_t; 56 57typedef int processorid_t; 58 59typedef ulong_t Lmid_t; /* link map id. Required in dt_pid.c */ 60 61typedef int lwpstatus_t; /* In lieu of Solaris <sys/procfs_isa.h>. Required in dt_proc.c */ 62 63#define fork1 fork 64#define fseeko64 fseeko 65#define ftello64 ftello 66#define ftruncate64 ftruncate 67#define lseek64 lseek 68#define open64 open 69#define fstat64 fstat 70#define mmap64 mmap 71#define open64 open 72#define pread64 pread 73#define stat64 stat 74 75#define pthread_cond_reltimedwait_np pthread_cond_timedwait_relative_np 76 77#define S_ROUND(x, a) ((x) + (((a) ? (a) : 1) - 1) & ~(((a) ? (a) : 1) - 1)) 78#define P2ROUNDUP(x, align) (-(-(x) & -(align))) 79 80#define SEC 1 81#define MILLISEC 1000 82#define MICROSEC 1000000 83#define NANOSEC 1000000000 84 85#define P_ONLINE 0x0002 /* processor is online */ 86#define P_STATUS 0x0003 /* value passed to p_online to request status */ 87 88// Solaris sysconf(3) selectors. Absent from Darwin unistd.h. dt_sysconf() can deal. 89#define _SC_CPUID_MAX -1 90#define _SC_NPROCESSORS_MAX -2 91 92// Solaris sysinfo selectors. Mapped to Darwin sysctl's in sysinfo(). 93#define SI_ISALIST 1 94#define SI_SYSNAME 2 95#define SI_RELEASE 3 96 97#define GLOBAL_ZONEID 0 // Darwin has no notion of zones(5). Always return 0. 98 99extern projid_t getprojid(void); // Darwin has no notion of project. Always return 0. 100extern taskid_t gettaskid(void); // Darwin has no notion of task. Always return 0. 101extern zoneid_t getzoneid(void); // Darwin has no notion of zones(5). Always return 0. 102 103extern int gmatch(const char *, const char *); 104extern int p_online(processorid_t, int); 105extern long sysinfo(int, char *, long); 106 107#define R_AMD64_64 1 /* from elf_amd64.h */ 108 109// The following are used only for "assert()" 110struct _rwlock; 111struct _lwp_mutex; 112extern int _rw_read_held(struct _rwlock *); 113extern int _rw_write_held(struct _rwlock *); 114extern int _mutex_held(struct _lwp_mutex *); 115 116#endif /* _DARWIN_SHIM_H */ 117