Mercurial > vba-clojure
view src/Port.h @ 442:58fe9c35d7c9
discovered meanig of first 8 bytes of music.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Thu, 26 Apr 2012 05:45:16 -0500 |
parents | 48369c6aeaa0 |
children |
line wrap: on
line source
1 #ifndef VBA_PORT_H2 #define VBA_PORT_H4 #if _MSC_VER > 10005 #pragma once6 #endif // _MSC_VER > 10008 #include <ctime>10 #ifndef NULL11 #define NULL 012 #endif14 typedef unsigned char bool8;16 //#ifdef HAVE_STDINT_H17 #include <stdint.h>19 // RLM combatibility junk21 typedef uint8_t u8;22 typedef uint16_t u16;23 typedef uint32_t u32;24 typedef uint64_t u64;26 typedef int8_t s8;27 typedef int16_t s16;28 typedef int32_t s32;29 typedef int64_t s64;32 typedef int8_t int8;33 typedef uint8_t uint8;34 typedef int16_t int16;35 typedef uint16_t uint16;36 typedef int32_t int32;37 typedef uint32_t uint32;38 typedef int64_t int64;39 typedef uint64_t uint64;40 typedef intptr_t pint;42 #ifndef WIN3244 #ifndef PATH_MAX45 #define PATH_MAX 102446 #endif48 #define _MAX_DIR PATH_MAX49 #define _MAX_DRIVE 150 #define _MAX_FNAME PATH_MAX51 #define _MAX_EXT PATH_MAX52 #define _MAX_PATH PATH_MAX54 #define ZeroMemory(a, b) memset((a), 0, (b))56 void _makepath(char *path, const char *drive, const char *dir,57 const char *fname, const char *ext);58 void _splitpath(const char *path, char *drive, char *dir, char *fname,59 char *ext);60 #else /* WIN32 */61 #define strcasecmp stricmp62 #define strncasecmp strnicmp63 #endif66 // for consistency67 static inline u8 swap8(u8 v)68 {69 return v;70 }72 // swaps a 16-bit value73 static inline u16 swap16(u16 v)74 {75 return (v<<8)|(v>>8);76 }78 // swaps a 32-bit value79 static inline u32 swap32(u32 v)80 {81 return (v<<24)|((v<<8)&0xff0000)|((v>>8)&0xff00)|(v>>24);82 }84 #define READ8LE(x) \85 *((u8 *)x)87 #define WRITE8LE(x, v) \88 *((u8 *)x) = (v)90 #ifdef WORDS_BIGENDIAN91 #if defined(__GNUC__) && defined(__ppc__)93 #define READ16LE(base) \94 ({ unsigned short lhbrxResult; \95 __asm__("lhbrx %0, 0, %1" : "=r" (lhbrxResult) : "r" (base) : "memory"); \96 lhbrxResult; })98 #define READ32LE(base) \99 ({ unsigned long lwbrxResult; \100 __asm__("lwbrx %0, 0, %1" : "=r" (lwbrxResult) : "r" (base) : "memory"); \101 lwbrxResult; })103 #define WRITE16LE(base, value) \104 __asm__("sthbrx %0, 0, %1" : : "r" (value), "r" (base) : "memory")106 #define WRITE32LE(base, value) \107 __asm__("stwbrx %0, 0, %1" : : "r" (value), "r" (base) : "memory")109 #else110 #define READ16LE(x) \111 swap16(*((u16 *)(x)))112 #define READ32LE(x) \113 swap32(*((u32 *)(x)))114 #define WRITE16LE(x, v) \115 *((u16 *)x) = swap16((v))116 #define WRITE32LE(x, v) \117 *((u32 *)x) = swap32((v))118 #endif119 #else120 #define READ16LE(x) \121 *((u16 *)x)122 #define READ32LE(x) \123 *((u32 *)x)124 #define WRITE16LE(x, v) \125 *((u16 *)x) = (v)126 #define WRITE32LE(x, v) \127 *((u32 *)x) = (v)128 #endif130 #ifndef CTASSERT131 #define CTASSERT(x) typedef char __assert ## y[(x) ? 1 : -1];132 #endif134 #endif // VBA_PORT_H