1/* BEGIN LICENSE BLOCK 2 * Version: CMPL 1.1 3 * 4 * The contents of this file are subject to the Cisco-style Mozilla Public 5 * License Version 1.1 (the "License"); you may not use this file except 6 * in compliance with the License. You may obtain a copy of the License 7 * at www.eclipse-clp.org/license. 8 * 9 * Software distributed under the License is distributed on an "AS IS" 10 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 11 * the License for the specific language governing rights and limitations 12 * under the License. 13 * 14 * The Original Code is The ECLiPSe Constraint Logic Programming System. 15 * The Initial Developer of the Original Code is Cisco Systems, Inc. 16 * Portions created by the Initial Developer are 17 * Copyright (C) 1994-2006 Cisco Systems, Inc. All Rights Reserved. 18 * 19 * Contributor(s): Kees Schuerman, ECRC 20 * 21 * END LICENSE BLOCK */ 22/********************************************************************** 23** System: Parallel Distributed System 24** File: pds.types.h 25** Author: Kees Schuerman 26** SccsId: "@(#)pds.types.h 1.7 5/15/95" 27** Description: Generic Data Type Definitions 28***********************************************************************/ 29 30#ifndef _PDS_TYPES_H_ 31#define _PDS_TYPES_H_ 32 33 34/* 35** Simple Data Types 36*/ 37 38typedef char pds_char; 39typedef unsigned char pds_uchar; 40typedef char pds_int8; 41typedef unsigned char pds_uint8; 42typedef short pds_int16; 43typedef unsigned short pds_uint16; 44typedef int pds_int32; 45typedef unsigned int pds_uint32; 46typedef float pds_sp_float; 47typedef double pds_dp_float; 48 49#define INT8_MIN -0x80 50#define INT8_MAX 0x7F 51#define INT16_MIN -0x8000 52#define INT16_MAX 0x7FFF 53#define UINT16_MAX 0xFFFF 54#define INT32_MIN -0x80000000 55#define INT32_MAX 0x7FFFFFFF 56#define UINT32_MAX 0xFFFFFFFF 57 58#if HAVE_NO_VOID_PTR 59typedef char * void_ptr; 60#else 61typedef void * void_ptr; 62#endif 63 64 65 66/* 67** Basic Data Types 68*/ 69 70typedef pds_uint8 pds_byte_t; 71typedef pds_uint16 pds_half_word_t; 72typedef pds_uint32 pds_word_t; 73 74#if WORDS_BIGENDIAN 75typedef struct { 76 pds_word_t high; 77 pds_word_t low; 78} pds_double_word_t; 79#else /* LITTLE ENDIAN */ 80typedef struct { 81 pds_word_t low; 82 pds_word_t high; 83} pds_double_word_t; 84#endif /* WORDS_BIGENDIAN */ 85 86#define PDS_BYTE_MAX 0XFF 87#define PDS_HALF_WORD_MAX 0XFFFF 88#define PDS_WORD_MAX 0XFFFFFFFF 89 90 91/* 92** More Data Types 93*/ 94 95#define PDS_PAD_BYTES (sizeof(pds_double_word_t) - sizeof(void_ptr)) 96#define PDS_PAD_BITS (8 * PDS_PAD_BYTES) 97 98typedef struct { 99#if WORDS_BIGENDIAN 100 unsigned : PDS_PAD_BITS; /* pad */ 101 void_ptr address; 102#else /* LITTLE ENDIAN */ 103 void_ptr address; 104 unsigned : PDS_PAD_BITS; /* pad */ 105#endif /* WORDS_BIGENDIAN */ 106} pds_address_t; 107 108#if WORDS_BIGENDIAN 109#define PDS_ADDR_OFFSET (-PDS_PAD_BYTES) 110#else /* LITTLE ENDIAN */ 111#define PDS_ADDR_OFFSET 0 112#endif /* WORDS_BIGENDIAN */ 113 114typedef pds_uint32 pds_size_t; 115typedef pds_int32 pds_ret_t; 116 117 118 119/* 120** Generic Data Truncate, Round, and Swap Macros 121*/ 122 123/* pds_word_truncate(pds_word_t word) */ 124 125#define pds_word_truncate(word) \ 126 ((word) - (word) % sizeof(pds_word_t)) 127 128 129/* pds_word_round(pds_word_t word) */ 130 131#define pds_word_round(word) \ 132 (pds_word_truncate((word) + sizeof(pds_word_t) -1)) 133 134 135/* pds_dword_truncate(pds_word_t word) */ 136 137#define pds_dword_truncate(word) \ 138 ((word) - (word) % sizeof(pds_double_word_t)) 139 140 141/* pds_dword_round(pds_word_t word) */ 142 143#define pds_dword_round(word) \ 144 (pds_dword_truncate((word) + sizeof(pds_double_word_t) -1)) 145 146 147/* hword_byte_swap(pds_half_word_t * hword) */ 148 149#define hword_byte_swap(hword) { \ 150 pds_half_word_t tmp; \ 151 pds_byte_t * s = (pds_byte_t *) (hword); \ 152 pds_byte_t * d = (pds_byte_t *) &tmp; \ 153 { \ 154 d[0] = s[1]; \ 155 d[1] = s[0]; \ 156 *(hword) = tmp; \ 157 } \ 158} 159 160 161/* word_byte_swap(pds_word_t * word) */ 162 163#define word_byte_swap(word) { \ 164 pds_word_t tmp; \ 165 pds_byte_t * s = (pds_byte_t *) (word); \ 166 pds_byte_t * d = (pds_byte_t *) &tmp; \ 167 { \ 168 d[0] = s[3]; \ 169 d[1] = s[2]; \ 170 d[2] = s[1]; \ 171 d[3] = s[0]; \ 172 *(word) = tmp; \ 173 } \ 174} 175 176 177/* dword_byte_swap(pds_double_word_t * dword) */ 178 179#define dword_byte_swap(dword) { \ 180 pds_double_word_t tmp; \ 181 pds_byte_t * s = (pds_byte_t *) (dword); \ 182 pds_byte_t * d = (pds_byte_t *) &tmp; \ 183 { \ 184 d[0] = s[7]; \ 185 d[1] = s[6]; \ 186 d[2] = s[5]; \ 187 d[3] = s[4]; \ 188 d[4] = s[3]; \ 189 d[5] = s[2]; \ 190 d[6] = s[1]; \ 191 d[7] = s[0]; \ 192 *(dword) = tmp; \ 193 } \ 194} 195 196#endif /* _PDS_TYPES_H_ */ 197