added clean rule and a bunch of definitions

This commit is contained in:
Amy G. Bowersox 2019-12-02 23:30:46 -07:00
parent 421d441ad0
commit 0849582c7b
3 changed files with 213 additions and 1 deletions

View File

@ -6,3 +6,6 @@ upiwin: $(OBJS)
.c.o:
gcc -c $(CFLAGS) $<
clean:
rm -f upiwin *.o *~

68
src/scode.h Normal file
View File

@ -0,0 +1,68 @@
#ifndef __SCODE_H_INCLUDED
#define __SCODE_H_INCLUDED
#include <wintype.h>
/*-------------------------------------------------------------------
* Status codes are defined as follows:
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* |S| Facility | Code |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 9 8 7 6 5 4 3 2 1 0
* 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
*
* S = Severity: 0 = success, 1 = error
* Facility = Facility code
* Code = Specific error code
*-------------------------------------------------------------------
*/
/* Severity codes */
#define SEVERITY_SUCCESS 0x00000000
#define SEVERITY_ERROR 0x80000000
/* Facility codes - compatible with M$ */
#define FACILITY_NULL 0
#define FACILITY_RPC 1
#define FACILITY_STORAGE 3
#define FACILITY_ITF 4
#define FACILITY_UNIX 5
#define FACILITY_UPIWIN 6
#define SUCCEEDED(s) (((s) & SEVERITY_ERROR) == 0)
#define FAILED(s) (((s) & SEVERITY_ERROR) != 0)
#define SCODE_FACILITY(s) (((s) >> 16) & 0x7FFF)
#define SCODE_CODE(s) ((s) & 0xFFFF)
#define MAKE_SCODE(sev, fac, err) ((SCODE)((sev) | (((fac) & 0x7FFF) << 16) | ((err) & 0xFFFF)))
#define ERRNO_AS_SCODE MAKE_SCODE(SEVERITY_ERROR, FACILITY_UNIX, errno)
#define SCODE_CAST(x) ((SCODE)(x))
/* Basic success codes */
#define S_OK SCODE_CAST(0x00000000) /* OK return */
#define S_FALSE SCODE_CAST(0x00000001) /* "False" return */
/* Basic error codes */
#define E_NOTIMPL SCODE_CAST(0x80000001) /* not implemented */
#define E_OUTOFMEMORY SCODE_CAST(0x80000002) /* out of memory */
#define E_INVALIDARG SCODE_CAST(0x80000003) /* invalid argument */
#define E_NOINTERFACE SCODE_CAST(0x80000004) /* no such interface */
#define E_POINTER SCODE_CAST(0x80000005) /* invalid pointer */
#define E_HANDLE SCODE_CAST(0x80000006) /* invalid handle */
#define E_ABORT SCODE_CAST(0x80000007) /* aborted operation */
#define E_FAIL SCODE_CAST(0x80000008) /* unspecified failure */
#define E_ACCESSDENIED SCODE_CAST(0x80000009) /* access denied */
#define E_PENDING SCODE_CAST(0x8000000A) /* data not yet available */
#define E_BOUNDS SCODE_CAST(0x8000000B) /* access outside valid range */
#define E_CHANGED_STATE SCODE_CAST(0x8000000C) /* object changed state, result now invalid */
#define E_ILLEGAL_STATE_CHANGE SCODE_CAST(0x8000000D) /* illegal state change */
#define E_ILLEGAL_METHOD_CALL SCODE_CAST(0x8000000E) /* illegal method call */
#define E_UNEXPECTED SCODE_CAST(0x8000FFFF) /* unexpected error */
/* UPIWIN-specific errorcodes */
#define UPIWIN_E_OUTOFRANGE SCODE_CAST(0x80060000) /* value out of range */
#endif /* __SCODE_H_INCLUDED */

View File

@ -3,6 +3,147 @@
#include <stdint.h>
typedef uint64_t TIMESTAMP;
/* Integral limit values */
/*#define INT16_MIN 0x8000 - defined in stdint.h */
/*#define INT16_MAX 0x7FFF - defined in stdint.h */
#define UINT16_MIN 0
/*#define UINT16_MAX 0xFFFF - defined in stdint.h*/
/*#define INT32_MIN 0x80000000 - defined in stdint.h*/
/*#define INT32_MAX 0x7FFFFFFF - defined in stdint.h*/
#define UINT32_MIN 0
/*#define UINT32_MAX 0xFFFFFFFF - defined in stdint.h*/
/*#define INT64_MIN 0x8000000000000000 - defined in stdint.h*/
/*#define INT64_MAX 0x7FFFFFFFFFFFFFFF - defined in stdint.h*/
#define UINT64_MIN 0
/*#define UINT64_MAX 0xFFFFFFFFFFFFFFFF - defined in stdint.h*/
#define INT_PTR_MIN INTPTR_MIN
#define INT_PTR_MAX INTPTR_MAX
#define UINT_PTR_MIN 0
#define UINT_PTR_MAX UINTPTR_MAX
#define DWORD_MIN UINT32_MIN
#define DWORD_MAX UINT32_MAX
/* Number of bits */
#define INT16_BITS 16
#define UINT16_BITS 16
#define INT32_BITS 32
#define UINT32_BITS 32
#define INT64_BITS 64
#define UINT64_BITS 64
#define LOG_PTRSIZE 2 /* log2(sizeof(void *)) */
#define LOG_INTSIZE 2 /* log2(sizeof(int)) */
#define LOG_UINTSIZE 2 /* log2(sizeof(UINT32)) */
#define LOG_INT64SIZE 3 /* log2(sizeof(long long)) */
#define PTRSIZE (1U << LOG_PTRSIZE)
#define PTR_MASK (PTRSIZE - 1)
#define PTR_CEILING(a) (((a) + PTR_MASK) & ~PTR_MASK)
/* Boolean values */
#define TRUE 1
#define FALSE 0
/* NULL value */
#ifndef NULL
#define NULL 0
#endif
/* Integral types */
typedef int16_t INT16;
typedef uint16_t UINT16;
typedef int32_t INT32;
typedef uint32_t UINT32;
typedef int64_t INT64;
typedef uint64_t UINT64;
typedef UINT16 WORD;
typedef UINT32 DWORD;
typedef UINT64 QWORD;
typedef INT32 LONG;
typedef UINT32 ULONG;
typedef INT64 LONG64;
typedef UINT64 ULONG64;
typedef INT32 INT;
typedef UINT32 UINT;
typedef INT64 LONGLONG;
typedef UINT64 ULONGLONG;
typedef intptr_t INT_PTR;
typedef uintptr_t UINT_PTR;
typedef UINT_PTR SIZE_T;
typedef INT_PTR SSIZE_T;
/* Base pointer types */
typedef INT16 *PINT16;
typedef UINT16 *PUINT16;
typedef INT32 *PINT32;
typedef UINT32 *PUINT32;
typedef INT64 *PINT64;
typedef UINT64 *PUINT64;
typedef SIZE_T *PSIZE_T;
typedef void *PVOID;
typedef const void *PCVOID;
typedef WORD *PWORD;
typedef DWORD *PDWORD;
typedef QWORD *PQWORD;
typedef LONGLONG *PLONGLONG;
typedef ULONGLONG *PULONGLONG;
/* Pointer-to-pointer types */
typedef PVOID *PPVOID;
/* Character types */
typedef char CHAR;
typedef unsigned char UCHAR;
typedef unsigned char BYTE;
typedef uint16_t WCHAR;
typedef CHAR *PCHAR;
typedef const CHAR *PCCHAR;
typedef UCHAR *PUCHAR;
typedef BYTE *PBYTE;
typedef const BYTE *PCBYTE;
typedef WCHAR *PWCHAR;
typedef const WCHAR *PCWCHAR;
typedef PCCHAR *PPCCHAR;
typedef CHAR *PSTR;
typedef const CHAR *PCSTR;
typedef WCHAR *PWSTR;
typedef const WCHAR *PCWSTR;
/* Boolean type */
typedef int BOOL;
/* Handle type */
typedef UINT_PTR HANDLE;
typedef HANDLE *PHANDLE;
/* Status code/result types */
typedef UINT32 SCODE;
typedef SCODE *PSCODE;
typedef SCODE HRESULT;
typedef UINT64 TIMESTAMP;
#define MAKEBOOL(val) ((val) ? TRUE : FALSE)
#define OFFSETOF(struc, field) ((UINT_PTR)(&(((struc *)0)->field)))
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define MAKEWORD(a, b) ((WORD)((((UINT_PTR)(a)) & 0xFF) | ((((UINT_PTR)(b)) & 0xFF) << 8)))
#define MAKELONG(a, b) ((LONG)((((UINT_PTR)(a)) & 0xFFFF) | ((((UINT_PTR)(b)) & 0xFFFF) << 16)))
#define MAKELONG64(a, b) ((LONG64)((((UINT64)(a)) & 0xFFFFFFFF) | ((((UINT64)(b)) & 0xFFFFFFFF) << 32)))
#define LODWORD(l) ((DWORD)(((UINT64)(l)) & 0xFFFFFFFF))
#define HIDWORD(l) ((DWORD)((((UINT64)(l)) >> 32) & 0xFFFFFFFF))
#define LOWORD(l) ((WORD)(((UINT_PTR)(l)) & 0xFFFF))
#define HIWORD(l) ((WORD)((((UINT_PTR)(l)) >> 16) & 0xFFFF))
#define LOBYTE(w) ((BYTE)(((UINT_PTR)(w)) & 0xFF))
#define HIBYTE(w) ((BYTE)((((UINT_PTR)(w)) >> 8) & 0xFF))
#endif /* __WINTYPE_H_INCLUDED */