#ifndef _PPCPRAGMA_MIAMI_H
#define _PPCPRAGMA_MIAMI_H

#ifndef POWERUP_PPCLIB_INTERFACE_H
#include <powerup/ppclib/interface.h>
#endif

#ifndef POWERUP_GCCLIB_PROTOS_H
#include <powerup/gcclib/powerup_protos.h>
#endif

#ifndef _STRING_H
#include <string.h>
#endif

#ifndef NO_PPCINLINE_STDARG
#define NO_PPCINLINE_STDARG
#endif/* SAS C PPC inlines */

#ifndef MIAMI_BASE_NAME
#define MIAMI_BASE_NAME MiamiBase
#endif

#define MiamiSysCtl(n,nl,o,ol,new,newl) _MiamiSysCtl(MIAMI_BASE_NAME,n,nl,o,ol,new,newl)

static __inline long
_MiamiSysCtl(void *MiamiBase,long *n,unsigned long nl,void *o,unsigned long *ol,
 void *new,unsigned long newl) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.a0=(ULONG)n;
	MyCaos.d0=(ULONG)nl;
	MyCaos.a1=(ULONG)o;
	MyCaos.a2=(ULONG)ol;
	MyCaos.a3=(ULONG)new;
	MyCaos.d1=(ULONG)newl;
	MyCaos.caos_Un.Offset=-30;
	MyCaos.a6=(ULONG)MiamiBase;
	return (long)PPCCallOS(&MyCaos);
}

#define MiamiDisallowDNS(v) _MiamiDisallowDNS(MIAMI_BASE_NAME,v)

static __inline void
_MiamiDisallowDNS(void *MiamiBase,long v) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.d0=(ULONG)v;
	MyCaos.caos_Un.Offset=-66;
	MyCaos.a6=(ULONG)MiamiBase;
	PPCCallOS(&MyCaos);
}

#define MiamiGetPid() _MiamiGetPid(MIAMI_BASE_NAME)

static __inline void *
_MiamiGetPid(void *MiamiBase) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.caos_Un.Offset=-78;
	MyCaos.a6=(ULONG)MiamiBase;
	return (void *)PPCCallOS(&MyCaos);
}

#define MiamiPFAddHook(hook,name,tags) _MiamiPFAddHook(MIAMI_BASE_NAME,hook,name,tags)

static __inline void *
_MiamiPFAddHook(void *MiamiBase,struct Hook *hook,unsigned char *name,
 struct TagItem *tags) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.a0=(ULONG)hook;
	MyCaos.a1=(ULONG)name;
	MyCaos.a2=(ULONG)tags;
	MyCaos.caos_Un.Offset=-96;
	MyCaos.a6=(ULONG)MiamiBase;
	return (void *)PPCCallOS(&MyCaos);
}

#define MiamiPFRemoveHook(handle) _MiamiPFRemoveHook(MIAMI_BASE_NAME,handle)

static __inline void
_MiamiPFRemoveHook(void *MiamiBase,void *handle) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.a0=(ULONG)handle;
	MyCaos.caos_Un.Offset=-102;
	MyCaos.a6=(ULONG)MiamiBase;
	PPCCallOS(&MyCaos);
}

#define MiamiGetHardwareLen(name) _MiamiGetHardwareLen(MIAMI_BASE_NAME,name)

static __inline long
_MiamiGetHardwareLen(void *MiamiBase,unsigned char *name) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.a0=(ULONG)name;
	MyCaos.caos_Un.Offset=-108;
	MyCaos.a6=(ULONG)MiamiBase;
	return (long)PPCCallOS(&MyCaos);
}

#define MiamiOpenSSL(tags) _MiamiOpenSSL(MIAMI_BASE_NAME,tags)

static __inline struct Library *
_MiamiOpenSSL(void *MiamiBase,struct TagItem *tags) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.a0=(ULONG)tags;
	MyCaos.caos_Un.Offset=-150;
	MyCaos.a6=(ULONG)MiamiBase;
	return (struct Library *)PPCCallOS(&MyCaos);
}

#define MiamiCloseSSL() _MiamiCloseSSL(MIAMI_BASE_NAME)

static __inline void
_MiamiCloseSSL(void *MiamiBase) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.caos_Un.Offset=-156;
	MyCaos.a6=(ULONG)MiamiBase;
	PPCCallOS(&MyCaos);
}

#define MiamiSetSocksConn(in,len) _MiamiSetSocksConn(MIAMI_BASE_NAME,in,len)

static __inline long
_MiamiSetSocksConn(void *MiamiBase,struct sockaddr *in,long len) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.a0=(ULONG)in;
	MyCaos.d0=(ULONG)len;
	MyCaos.caos_Un.Offset=-198;
	MyCaos.a6=(ULONG)MiamiBase;
	return (long)PPCCallOS(&MyCaos);
}

#define MiamiIsOnline(name) _MiamiIsOnline(MIAMI_BASE_NAME,name)

static __inline long
_MiamiIsOnline(void *MiamiBase,char *name) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.a0=(ULONG)name;
	MyCaos.caos_Un.Offset=-210;
	MyCaos.a6=(ULONG)MiamiBase;
	return (long)PPCCallOS(&MyCaos);
}

#define MiamiOnOffline(name,val) _MiamiOnOffline(MIAMI_BASE_NAME,name,val)

static __inline void
_MiamiOnOffline(void *MiamiBase,char *name,long val) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.a0=(ULONG)name;
	MyCaos.d0=(ULONG)val;
	MyCaos.caos_Un.Offset=-216;
	MyCaos.a6=(ULONG)MiamiBase;
	PPCCallOS(&MyCaos);
}

#define inet_ntop(f,a,s,l) _inet_ntop(MIAMI_BASE_NAME,f,a,s,l)

static __inline char *
_inet_ntop(void *MiamiBase,long f,void *a,char *s,long l) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.d0=(ULONG)f;
	MyCaos.a0=(ULONG)a;
	MyCaos.a1=(ULONG)s;
	MyCaos.d1=(ULONG)l;
	MyCaos.caos_Un.Offset=-228;
	MyCaos.a6=(ULONG)MiamiBase;
	return (char *)PPCCallOS(&MyCaos);
}

#define inet_aton(c,a) _inet_aton(MIAMI_BASE_NAME,c,a)

static __inline long
_inet_aton(void *MiamiBase,char *c,struct in_addr *a) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.a0=(ULONG)c;
	MyCaos.a1=(ULONG)a;
	MyCaos.caos_Un.Offset=-234;
	MyCaos.a6=(ULONG)MiamiBase;
	return (long)PPCCallOS(&MyCaos);
}

#define inet_pton(f,s,a) _inet_pton(MIAMI_BASE_NAME,f,s,a)

static __inline long
_inet_pton(void *MiamiBase,long f,char *s,struct in_addr *a) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.d0=(ULONG)f;
	MyCaos.a0=(ULONG)s;
	MyCaos.a1=(ULONG)a;
	MyCaos.caos_Un.Offset=-240;
	MyCaos.a6=(ULONG)MiamiBase;
	return (long)PPCCallOS(&MyCaos);
}

#define gethostbyname2(n,f) _gethostbyname2(MIAMI_BASE_NAME,n,f)

static __inline struct hostent *
_gethostbyname2(void *MiamiBase,char *n,long f) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.a0=(ULONG)n;
	MyCaos.d0=(ULONG)f;
	MyCaos.caos_Un.Offset=-246;
	MyCaos.a6=(ULONG)MiamiBase;
	return (struct hostent *)PPCCallOS(&MyCaos);
}

#define gai_strerror(e) _gai_strerror(MIAMI_BASE_NAME,e)

static __inline char *
_gai_strerror(void *MiamiBase,long e) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.d0=(ULONG)e;
	MyCaos.caos_Un.Offset=-252;
	MyCaos.a6=(ULONG)MiamiBase;
	return (char *)PPCCallOS(&MyCaos);
}

#define freeaddrinfo(a) _freeaddrinfo(MIAMI_BASE_NAME,a)

static __inline void
_freeaddrinfo(void *MiamiBase,struct addrinfo *a) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.a0=(ULONG)a;
	MyCaos.caos_Un.Offset=-258;
	MyCaos.a6=(ULONG)MiamiBase;
	PPCCallOS(&MyCaos);
}

#define getaddrinfo(h,s,hi,r) _getaddrinfo(MIAMI_BASE_NAME,h,s,hi,r)

static __inline long
_getaddrinfo(void *MiamiBase,char *h,char *s,struct addrinfo *hi,struct addrinfo **r) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.a0=(ULONG)h;
	MyCaos.a1=(ULONG)s;
	MyCaos.a2=(ULONG)hi;
	MyCaos.a3=(ULONG)r;
	MyCaos.caos_Un.Offset=-264;
	MyCaos.a6=(ULONG)MiamiBase;
	return (long)PPCCallOS(&MyCaos);
}

#define getnameinfo(s,sl,h,hl,se,sel,f) _getnameinfo(MIAMI_BASE_NAME,s,sl,h,hl,se,sel,f)

static __inline long
_getnameinfo(void *MiamiBase,struct sockaddr *s,long sl,char *h,long hl,
 char *se,long sel,long f) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.a0=(ULONG)s;
	MyCaos.d0=(ULONG)sl;
	MyCaos.a1=(ULONG)h;
	MyCaos.d1=(ULONG)hl;
	MyCaos.a2=(ULONG)se;
	MyCaos.d2=(ULONG)sel;
	MyCaos.d3=(ULONG)f;
	MyCaos.caos_Un.Offset=-270;
	MyCaos.a6=(ULONG)MiamiBase;
	return (long)PPCCallOS(&MyCaos);
}

#define if_nametoindex(in) _if_nametoindex(MIAMI_BASE_NAME,in)

static __inline long
_if_nametoindex(void *MiamiBase,char *in) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.a0=(ULONG)in;
	MyCaos.caos_Un.Offset=-276;
	MyCaos.a6=(ULONG)MiamiBase;
	return (long)PPCCallOS(&MyCaos);
}

#define if_indextoname(in,n) _if_indextoname(MIAMI_BASE_NAME,in,n)

static __inline char *
_if_indextoname(void *MiamiBase,long in,char *n) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.d0=(ULONG)in;
	MyCaos.a0=(ULONG)n;
	MyCaos.caos_Un.Offset=-282;
	MyCaos.a6=(ULONG)MiamiBase;
	return (char *)PPCCallOS(&MyCaos);
}

#define if_nameindex() _if_nameindex(MIAMI_BASE_NAME)

static __inline struct if_nameindex *
_if_nameindex(void *MiamiBase) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.caos_Un.Offset=-288;
	MyCaos.a6=(ULONG)MiamiBase;
	return (struct if_nameindex *)PPCCallOS(&MyCaos);
}

#define if_freenameindex(p) _if_freenameindex(MIAMI_BASE_NAME,p)

static __inline void
_if_freenameindex(void *MiamiBase,struct if_nameindex *p) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.a0=(ULONG)p;
	MyCaos.caos_Un.Offset=-294;
	MyCaos.a6=(ULONG)MiamiBase;
	PPCCallOS(&MyCaos);
}

#define MiamiSupportsIPV6() _MiamiSupportsIPV6(MIAMI_BASE_NAME)

static __inline long
_MiamiSupportsIPV6(void *MiamiBase) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.caos_Un.Offset=-300;
	MyCaos.a6=(ULONG)MiamiBase;
	return (long)PPCCallOS(&MyCaos);
}

#define MiamiResGetOptions() _MiamiResGetOptions(MIAMI_BASE_NAME)

static __inline long
_MiamiResGetOptions(void *MiamiBase) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.caos_Un.Offset=-306;
	MyCaos.a6=(ULONG)MiamiBase;
	return (long)PPCCallOS(&MyCaos);
}

#define MiamiResSetOptions(o) _MiamiResSetOptions(MIAMI_BASE_NAME,o)

static __inline void
_MiamiResSetOptions(void *MiamiBase,long o) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.d0=(ULONG)o;
	MyCaos.caos_Un.Offset=-312;
	MyCaos.a6=(ULONG)MiamiBase;
	PPCCallOS(&MyCaos);
}

#define sockatmark(fd) _sockatmark(MIAMI_BASE_NAME,fd)

static __inline long
_sockatmark(void *MiamiBase,long fd) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.d0=(ULONG)fd;
	MyCaos.caos_Un.Offset=-318;
	MyCaos.a6=(ULONG)MiamiBase;
	return (long)PPCCallOS(&MyCaos);
}

#define MiamiSupportedCPUs(a,c,k) _MiamiSupportedCPUs(MIAMI_BASE_NAME,a,c,k)

static __inline void
_MiamiSupportedCPUs(void *MiamiBase,ULONG *a,ULONG *c,ULONG *k) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.a0=(ULONG)a;
	MyCaos.a1=(ULONG)c;
	MyCaos.a2=(ULONG)k;
	MyCaos.caos_Un.Offset=-324;
	MyCaos.a6=(ULONG)MiamiBase;
	PPCCallOS(&MyCaos);
}

#define MiamiGetFdCallback(c) _MiamiGetFdCallback(MIAMI_BASE_NAME,c)

static __inline long
_MiamiGetFdCallback(void *MiamiBase,void **c) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.a0=(ULONG)c;
	MyCaos.caos_Un.Offset=-330;
	MyCaos.a6=(ULONG)MiamiBase;
	return (long)PPCCallOS(&MyCaos);
}

#define MiamiSetFdCallback(c,t) _MiamiSetFdCallback(MIAMI_BASE_NAME,c,t)

static __inline long
_MiamiSetFdCallback(void *MiamiBase,void *c,long t) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.a0=(ULONG)c;
	MyCaos.d0=(ULONG)t;
	MyCaos.caos_Un.Offset=-336;
	MyCaos.a6=(ULONG)MiamiBase;
	return (long)PPCCallOS(&MyCaos);
}

#define MiamiGetCredentials() _MiamiGetCredentials(MIAMI_BASE_NAME)

static __inline struct UserGroupCredentials *
_MiamiGetCredentials(void *MiamiBase) {
	struct Caos MyCaos;
	MyCaos.M68kCacheMode=IF_CACHEFLUSHALL;
	MyCaos.PPCCacheMode=IF_CACHEFLUSHALL;
	MyCaos.caos_Un.Offset=-348;
	MyCaos.a6=(ULONG)MiamiBase;
	return (struct UserGroupCredentials *)PPCCallOS(&MyCaos);
}

#endif
