~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/drizzle_com.h

  • Committer: Monty Taylor
  • Date: 2008-10-21 06:29:09 UTC
  • mto: This revision was merged to the branch mainline in revision 533.
  • Revision ID: monty@inaugust.com-20081021062909-75ak4vsvuf8iojxe
Reverted too-big formatting change.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
#include <stdint.h>
31
31
 
32
32
/*
33
 
  This is included in the server and in the client.
34
 
  Options for select set by the yacc parser (stored in lex->options).
35
 
 
36
 
  XXX:
37
 
  log_event.h defines OPTIONS_WRITTEN_TO_BIN_LOG to specify what THD
38
 
  options list are written into binlog. These options can NOT change their
39
 
  values, or it will break replication between version.
40
 
 
41
 
  context is encoded as following:
42
 
  SELECT - SELECT_LEX_NODE::options
43
 
  THD    - THD::options
44
 
  intern - neither. used only as
45
 
  func(..., select_node->options | thd->options | OPTION_XXX, ...)
46
 
 
47
 
  TODO: separate three contexts above, move them to separate bitfields.
 
33
   This is included in the server and in the client.
 
34
   Options for select set by the yacc parser (stored in lex->options).
 
35
 
 
36
   XXX:
 
37
   log_event.h defines OPTIONS_WRITTEN_TO_BIN_LOG to specify what THD
 
38
   options list are written into binlog. These options can NOT change their
 
39
   values, or it will break replication between version.
 
40
 
 
41
   context is encoded as following:
 
42
   SELECT - SELECT_LEX_NODE::options
 
43
   THD    - THD::options
 
44
   intern - neither. used only as
 
45
            func(..., select_node->options | thd->options | OPTION_XXX, ...)
 
46
 
 
47
   TODO: separate three contexts above, move them to separate bitfields.
48
48
*/
49
49
 
50
50
#define SELECT_DISTINCT         (UINT64_C(1) << 0)     // SELECT, user
75
75
#define SELECT_ALL              (UINT64_C(1) << 24)    // SELECT, user, parser
76
76
 
77
77
/** The following can be set when importing tables in a 'wrong order'
78
 
    to suppress foreign key checks */
 
78
   to suppress foreign key checks */
79
79
#define OPTION_NO_FOREIGN_KEY_CHECKS    (UINT64_C(1) << 26) // THD, user, binlog
80
80
/** The following speeds up inserts to InnoDB tables by suppressing unique
81
 
    key checks in some cases */
 
81
   key checks in some cases */
82
82
#define OPTION_RELAXED_UNIQUE_CHECKS    (UINT64_C(1) << 27) // THD, user, binlog
83
83
#define SELECT_NO_UNLOCK                (UINT64_C(1) << 28) // SELECT, intern
84
84
#define OPTION_SCHEMA_TABLE             (UINT64_C(1) << 29) // SELECT, intern
87
87
/** If not set then the thread will ignore all warnings with level notes. */
88
88
#define OPTION_SQL_NOTES                (UINT64_C(1) << 31) // THD, user
89
89
/**
90
 
   Force the used temporary table to be a MyISAM table (because we will use
91
 
   fulltext functions when reading from it.
 
90
  Force the used temporary table to be a MyISAM table (because we will use
 
91
  fulltext functions when reading from it.
92
92
*/
93
93
#define TMP_TABLE_FORCE_MYISAM          (UINT64_C(1) << 32)
94
94
#define OPTION_PROFILING                (UINT64_C(1) << 33)
100
100
#define OPTION_ALLOW_BATCH              (UINT64_C(1) << 33) // THD, intern (slave)
101
101
 
102
102
/**
103
 
   Maximum length of time zone name that we support
104
 
   (Time zone name is char(64) in db). mysqlbinlog needs it.
 
103
  Maximum length of time zone name that we support
 
104
  (Time zone name is char(64) in db). mysqlbinlog needs it.
105
105
*/
106
106
#define MAX_TIME_ZONE_NAME_LENGTH       (NAME_LEN + 1)
107
107
 
171
171
#define SCRAMBLED_PASSWORD_CHAR_LENGTH_323 (SCRAMBLE_LENGTH_323*2)
172
172
 
173
173
 
174
 
#define NOT_NULL_FLAG  1    /* Field can't be NULL */
175
 
#define PRI_KEY_FLAG  2    /* Field is part of a primary key */
176
 
#define UNIQUE_KEY_FLAG 4    /* Field is part of a unique key */
177
 
#define MULTIPLE_KEY_FLAG 8    /* Field is part of a key */
178
 
#define BLOB_FLAG  16    /* Field is a blob */
179
 
#define UNSIGNED_FLAG  32    /* Field is unsigned */
180
 
#define DECIMAL_FLAG  64    /* Field is zerofill */
181
 
#define BINARY_FLAG  128    /* Field is binary   */
 
174
#define NOT_NULL_FLAG   1               /* Field can't be NULL */
 
175
#define PRI_KEY_FLAG    2               /* Field is part of a primary key */
 
176
#define UNIQUE_KEY_FLAG 4               /* Field is part of a unique key */
 
177
#define MULTIPLE_KEY_FLAG 8             /* Field is part of a key */
 
178
#define BLOB_FLAG       16              /* Field is a blob */
 
179
#define UNSIGNED_FLAG   32              /* Field is unsigned */
 
180
#define DECIMAL_FLAG    64              /* Field is zerofill */
 
181
#define BINARY_FLAG     128             /* Field is binary   */
182
182
 
183
183
/* The following are only sent to new clients */
184
 
#define ENUM_FLAG  256    /* field is an enum */
185
 
#define AUTO_INCREMENT_FLAG 512    /* field is a autoincrement field */
186
 
#define TIMESTAMP_FLAG  1024    /* Field is a timestamp */
187
 
#define SET_FLAG  2048    /* field is a set */
188
 
#define NO_DEFAULT_VALUE_FLAG 4096  /* Field doesn't have default value */
 
184
#define ENUM_FLAG       256             /* field is an enum */
 
185
#define AUTO_INCREMENT_FLAG 512         /* field is a autoincrement field */
 
186
#define TIMESTAMP_FLAG  1024            /* Field is a timestamp */
 
187
#define SET_FLAG        2048            /* field is a set */
 
188
#define NO_DEFAULT_VALUE_FLAG 4096      /* Field doesn't have default value */
189
189
#define ON_UPDATE_NOW_FLAG 8192         /* Field is set to NOW on UPDATE */
190
 
#define NUM_FLAG  32768    /* Field is num (for clients) */
191
 
#define PART_KEY_FLAG  16384    /* Intern; Part of some key */
192
 
#define GROUP_FLAG  32768    /* Intern: Group field */
193
 
#define UNIQUE_FLAG  65536    /* Intern: Used by sql_yacc */
194
 
#define BINCMP_FLAG  131072    /* Intern: Used by sql_yacc */
 
190
#define NUM_FLAG        32768           /* Field is num (for clients) */
 
191
#define PART_KEY_FLAG   16384           /* Intern; Part of some key */
 
192
#define GROUP_FLAG      32768           /* Intern: Group field */
 
193
#define UNIQUE_FLAG     65536           /* Intern: Used by sql_yacc */
 
194
#define BINCMP_FLAG     131072          /* Intern: Used by sql_yacc */
195
195
#define GET_FIXED_FIELDS_FLAG (1 << 18) /* Used to get fields in item tree */
196
196
#define FIELD_IN_PART_FUNC_FLAG (1 << 19)/* Field part of partition func */
197
 
#define FIELD_IN_ADD_INDEX (1<< 20)  /* Intern: Field used in ADD INDEX */
 
197
#define FIELD_IN_ADD_INDEX (1<< 20)     /* Intern: Field used in ADD INDEX */
198
198
#define FIELD_IS_RENAMED (1<< 21)       /* Intern: Field is being renamed */
199
199
#define FIELD_STORAGE_FLAGS 22          /* Storage type: bit 22, 23 and 24 */
200
200
#define COLUMN_FORMAT_FLAGS 25          /* Column format: bit 25, 26 and 27 */
201
201
 
202
 
#define REFRESH_GRANT    1  /* Refresh grant tables */
203
 
#define REFRESH_LOG    2  /* Start on new log file */
204
 
#define REFRESH_TABLES    4  /* close all tables */
205
 
#define REFRESH_HOSTS    8  /* Flush host cache */
206
 
#define REFRESH_STATUS    16  /* Flush status variables */
207
 
#define REFRESH_THREADS    32  /* Flush thread cache */
 
202
#define REFRESH_GRANT           1       /* Refresh grant tables */
 
203
#define REFRESH_LOG             2       /* Start on new log file */
 
204
#define REFRESH_TABLES          4       /* close all tables */
 
205
#define REFRESH_HOSTS           8       /* Flush host cache */
 
206
#define REFRESH_STATUS          16      /* Flush status variables */
 
207
#define REFRESH_THREADS         32      /* Flush thread cache */
208
208
#define REFRESH_SLAVE           64      /* Reset master info and restart slave
209
 
                                           thread */
 
209
                                           thread */
210
210
#define REFRESH_MASTER          128     /* Remove all bin logs in the index
211
 
                                           and truncate the index */
 
211
                                           and truncate the index */
212
212
 
213
213
/* The following can't be set with mysql_refresh() */
214
 
#define REFRESH_READ_LOCK  16384  /* Lock tables for read */
215
 
#define REFRESH_FAST    32768  /* Intern flag */
 
214
#define REFRESH_READ_LOCK       16384   /* Lock tables for read */
 
215
#define REFRESH_FAST            32768   /* Intern flag */
216
216
 
217
217
/* RESET (remove all queries) from query cache */
218
 
#define REFRESH_QUERY_CACHE  65536
 
218
#define REFRESH_QUERY_CACHE     65536
219
219
#define REFRESH_QUERY_CACHE_FREE 0x20000L /* pack query cache */
220
 
#define REFRESH_DES_KEY_FILE  0x40000L
221
 
#define REFRESH_USER_RESOURCES  0x80000L
 
220
#define REFRESH_DES_KEY_FILE    0x40000L
 
221
#define REFRESH_USER_RESOURCES  0x80000L
222
222
 
223
 
#define CLIENT_LONG_PASSWORD  1  /* new more secure passwords */
224
 
#define CLIENT_FOUND_ROWS  2  /* Found instead of affected rows */
225
 
#define CLIENT_LONG_FLAG  4  /* Get all column flags */
226
 
#define CLIENT_CONNECT_WITH_DB  8  /* One can specify db on connect */
227
 
#define CLIENT_NO_SCHEMA  16  /* Don't allow database.table.column */
228
 
#define CLIENT_COMPRESS    32  /* Can use compression protocol */
229
 
#define CLIENT_ODBC    64  /* Odbc client */
230
 
#define CLIENT_LOCAL_FILES  128  /* Can use LOAD DATA LOCAL */
231
 
#define CLIENT_IGNORE_SPACE  256  /* Ignore spaces before '(' */
232
 
#define UNUSED_CLIENT_PROTOCOL_41  512  /* New 4.1 protocol */
233
 
#define CLIENT_INTERACTIVE  1024  /* This is an interactive client */
234
 
#define CLIENT_SSL              2048  /* Switch to SSL after handshake */
 
223
#define CLIENT_LONG_PASSWORD    1       /* new more secure passwords */
 
224
#define CLIENT_FOUND_ROWS       2       /* Found instead of affected rows */
 
225
#define CLIENT_LONG_FLAG        4       /* Get all column flags */
 
226
#define CLIENT_CONNECT_WITH_DB  8       /* One can specify db on connect */
 
227
#define CLIENT_NO_SCHEMA        16      /* Don't allow database.table.column */
 
228
#define CLIENT_COMPRESS         32      /* Can use compression protocol */
 
229
#define CLIENT_ODBC             64      /* Odbc client */
 
230
#define CLIENT_LOCAL_FILES      128     /* Can use LOAD DATA LOCAL */
 
231
#define CLIENT_IGNORE_SPACE     256     /* Ignore spaces before '(' */
 
232
#define UNUSED_CLIENT_PROTOCOL_41       512     /* New 4.1 protocol */
 
233
#define CLIENT_INTERACTIVE      1024    /* This is an interactive client */
 
234
#define CLIENT_SSL              2048    /* Switch to SSL after handshake */
235
235
#define CLIENT_IGNORE_SIGPIPE   4096    /* IGNORE sigpipes */
236
 
#define CLIENT_TRANSACTIONS  8192  /* Client knows about transactions */
 
236
#define CLIENT_TRANSACTIONS     8192    /* Client knows about transactions */
237
237
#define CLIENT_RESERVED         16384   /* Old flag for 4.1 protocol  */
238
238
#define CLIENT_SECURE_CONNECTION 32768  /* New 4.1 authentication */
239
239
#define CLIENT_MULTI_STATEMENTS (1UL << 16) /* Enable/disable multi-stmt support */
243
243
#define CLIENT_REMEMBER_OPTIONS (1UL << 31)
244
244
 
245
245
/* Gather all possible capabilites (flags) supported by the server */
246
 
#define CLIENT_ALL_FLAGS  (CLIENT_LONG_PASSWORD |       \
247
 
                           CLIENT_FOUND_ROWS |          \
248
 
                           CLIENT_LONG_FLAG |           \
249
 
                           CLIENT_CONNECT_WITH_DB |     \
250
 
                           CLIENT_NO_SCHEMA |           \
251
 
                           CLIENT_COMPRESS |            \
252
 
                           CLIENT_ODBC |                \
253
 
                           CLIENT_LOCAL_FILES |         \
254
 
                           CLIENT_IGNORE_SPACE |        \
255
 
                           CLIENT_INTERACTIVE |         \
256
 
                           CLIENT_SSL |                 \
257
 
                           CLIENT_IGNORE_SIGPIPE |      \
258
 
                           CLIENT_TRANSACTIONS |        \
259
 
                           CLIENT_RESERVED |            \
260
 
                           CLIENT_SECURE_CONNECTION |   \
261
 
                           CLIENT_MULTI_STATEMENTS |    \
262
 
                           CLIENT_MULTI_RESULTS |          \
 
246
#define CLIENT_ALL_FLAGS  (CLIENT_LONG_PASSWORD | \
 
247
                           CLIENT_FOUND_ROWS | \
 
248
                           CLIENT_LONG_FLAG | \
 
249
                           CLIENT_CONNECT_WITH_DB | \
 
250
                           CLIENT_NO_SCHEMA | \
 
251
                           CLIENT_COMPRESS | \
 
252
                           CLIENT_ODBC | \
 
253
                           CLIENT_LOCAL_FILES | \
 
254
                           CLIENT_IGNORE_SPACE | \
 
255
                           CLIENT_INTERACTIVE | \
 
256
                           CLIENT_SSL | \
 
257
                           CLIENT_IGNORE_SIGPIPE | \
 
258
                           CLIENT_TRANSACTIONS | \
 
259
                           CLIENT_RESERVED | \
 
260
                           CLIENT_SECURE_CONNECTION | \
 
261
                           CLIENT_MULTI_STATEMENTS | \
 
262
                           CLIENT_MULTI_RESULTS | \
263
263
                           CLIENT_SSL_VERIFY_SERVER_CERT | \
264
264
                           CLIENT_REMEMBER_OPTIONS)
265
265
 
268
268
  If any of the optional flags is supported by the build it will be switched
269
269
  on before sending to the client during the connection handshake.
270
270
*/
271
 
#define CLIENT_BASIC_FLAGS (((CLIENT_ALL_FLAGS & ~CLIENT_SSL)      \
272
 
                             & ~CLIENT_COMPRESS)                        \
273
 
                            & ~CLIENT_SSL_VERIFY_SERVER_CERT)
 
271
#define CLIENT_BASIC_FLAGS (((CLIENT_ALL_FLAGS & ~CLIENT_SSL) \
 
272
                                               & ~CLIENT_COMPRESS) \
 
273
                                               & ~CLIENT_SSL_VERIFY_SERVER_CERT)
274
274
 
275
 
#define SERVER_STATUS_IN_TRANS     1  /* Transaction has started */
276
 
#define SERVER_STATUS_AUTOCOMMIT   2  /* Server in auto_commit mode */
 
275
#define SERVER_STATUS_IN_TRANS     1    /* Transaction has started */
 
276
#define SERVER_STATUS_AUTOCOMMIT   2    /* Server in auto_commit mode */
277
277
#define SERVER_MORE_RESULTS_EXISTS 8    /* Multi query - next query exists */
278
278
#define SERVER_QUERY_NO_GOOD_INDEX_USED 16
279
279
#define SERVER_QUERY_NO_INDEX_USED      32
297
297
*/
298
298
#define SERVER_QUERY_WAS_SLOW           1024
299
299
 
300
 
#define DRIZZLE_ERRMSG_SIZE  512
301
 
#define NET_READ_TIMEOUT  30    /* Timeout on read */
302
 
#define NET_WRITE_TIMEOUT  60    /* Timeout on write */
303
 
#define NET_WAIT_TIMEOUT  8*60*60    /* Wait for new query */
 
300
#define DRIZZLE_ERRMSG_SIZE     512
 
301
#define NET_READ_TIMEOUT        30              /* Timeout on read */
 
302
#define NET_WRITE_TIMEOUT       60              /* Timeout on write */
 
303
#define NET_WAIT_TIMEOUT        8*60*60         /* Wait for new query */
304
304
 
305
305
#define ONLY_KILL_QUERY         1
306
306
 
307
 
struct st_vio;          /* Only C */
 
307
struct st_vio;                                  /* Only C */
308
308
typedef struct st_vio Vio;
309
309
 
310
310
#define MAX_TINYINT_WIDTH       3       /* Max width for a TINY w.o. sign */
312
312
#define MAX_MEDIUMINT_WIDTH     8       /* Max width for a INT24 w.o. sign */
313
313
#define MAX_INT_WIDTH           10      /* Max width for a LONG w.o. sign */
314
314
#define MAX_BIGINT_WIDTH        20      /* Max width for a LONGLONG */
315
 
#define MAX_CHAR_WIDTH    255  /* Max length for a CHAR colum */
316
 
#define MAX_BLOB_WIDTH    16777216  /* Default width for blob */
 
315
#define MAX_CHAR_WIDTH          255     /* Max length for a CHAR colum */
 
316
#define MAX_BLOB_WIDTH          16777216        /* Default width for blob */
317
317
 
318
318
#define DRIZZLE_PROTOCOL_NO_MORE_DATA 0xFE
319
319
 
323
323
#define packet_error (~(uint32_t) 0)
324
324
 
325
325
 
326
 
/* Shutdown/kill enums and constants */
 
326
/* Shutdown/kill enums and constants */ 
327
327
 
328
328
/* Bits for THD::killable. */
329
329
#define DRIZZLE_SHUTDOWN_KILLABLE_CONNECT    (unsigned char)(1 << 0)
340
340
                        DRIZZLE_TYPE_TIME,
341
341
                        DRIZZLE_TYPE_DATETIME,
342
342
                        DRIZZLE_TYPE_NEWDATE, DRIZZLE_TYPE_VARCHAR,
343
 
                        DRIZZLE_TYPE_VIRTUAL,
 
343
                                          DRIZZLE_TYPE_VIRTUAL,
344
344
                        DRIZZLE_TYPE_NEWDECIMAL,
345
345
                        DRIZZLE_TYPE_ENUM,
346
346
                        DRIZZLE_TYPE_BLOB,
380
380
}
381
381
#endif
382
382
 
383
 
/* The following is for user defined functions */
 
383
  /* The following is for user defined functions */
384
384
 
385
385
enum Item_result {STRING_RESULT=0, REAL_RESULT, INT_RESULT, ROW_RESULT,
386
386
                  DECIMAL_RESULT};
387
387
 
388
388
typedef struct st_udf_args
389
389
{
390
 
  unsigned int arg_count;    /* Number of arguments */
391
 
  enum Item_result *arg_type;    /* Pointer to item_results */
392
 
  char **args;        /* Pointer to argument */
393
 
  unsigned long *lengths;    /* Length of string arguments */
394
 
  char *maybe_null;      /* Set to 1 for all maybe_null args */
 
390
  unsigned int arg_count;               /* Number of arguments */
 
391
  enum Item_result *arg_type;           /* Pointer to item_results */
 
392
  char **args;                          /* Pointer to argument */
 
393
  unsigned long *lengths;               /* Length of string arguments */
 
394
  char *maybe_null;                     /* Set to 1 for all maybe_null args */
395
395
  char **attributes;                    /* Pointer to attribute name */
396
396
  unsigned long *attribute_lengths;     /* Length of attribute arguments */
397
397
  void *extension;
398
398
} UDF_ARGS;
399
399
 
400
 
/* This holds information about the result */
 
400
  /* This holds information about the result */
401
401
 
402
402
typedef struct st_udf_init
403
403
{
408
408
  bool const_item;          /* 1 if function always returns the same value */
409
409
  void *extension;
410
410
} UDF_INIT;
411
 
/*
412
 
  TODO: add a notion for determinism of the UDF.
 
411
/* 
 
412
  TODO: add a notion for determinism of the UDF. 
413
413
  See Item_udf_func::update_used_tables ()
414
414
*/
415
415
 
416
 
/* Constants when using compression */
417
 
#define NET_HEADER_SIZE 4    /* standard header size */
418
 
#define COMP_HEADER_SIZE 3    /* compression header extra size */
 
416
  /* Constants when using compression */
 
417
#define NET_HEADER_SIZE 4               /* standard header size */
 
418
#define COMP_HEADER_SIZE 3              /* compression header extra size */
419
419
 
420
 
/* Prototypes to password functions */
 
420
  /* Prototypes to password functions */
421
421
 
422
422
#ifdef __cplusplus
423
423
extern "C" {
458
458
 
459
459
/* Optimized store functions for Intel x86 */
460
460
#if defined(__i386__)
461
 
#define sint2korr(A)  (*((int16_t *) (A)))
462
 
#define sint3korr(A)  ((int32_t) ((((unsigned char) (A)[2]) & 128) ?  \
463
 
                                    (((uint32_t) 255L << 24) |          \
464
 
                                     (((uint32_t) (unsigned char) (A)[2]) << 16) | \
465
 
                                     (((uint32_t) (unsigned char) (A)[1]) << 8) | \
466
 
                                     ((uint32_t) (unsigned char) (A)[0])) : \
467
 
                                    (((uint32_t) (unsigned char) (A)[2]) << 16) | \
468
 
                                    (((uint32_t) (unsigned char) (A)[1]) << 8) | \
469
 
                                    ((uint32_t) (unsigned char) (A)[0])))
470
 
#define sint4korr(A)  (*((long *) (A)))
471
 
#define uint2korr(A)  (*((uint16_t *) (A)))
 
461
#define sint2korr(A)    (*((int16_t *) (A)))
 
462
#define sint3korr(A)    ((int32_t) ((((unsigned char) (A)[2]) & 128) ? \
 
463
                                  (((uint32_t) 255L << 24) | \
 
464
                                   (((uint32_t) (unsigned char) (A)[2]) << 16) |\
 
465
                                   (((uint32_t) (unsigned char) (A)[1]) << 8) | \
 
466
                                   ((uint32_t) (unsigned char) (A)[0])) : \
 
467
                                  (((uint32_t) (unsigned char) (A)[2]) << 16) |\
 
468
                                  (((uint32_t) (unsigned char) (A)[1]) << 8) | \
 
469
                                  ((uint32_t) (unsigned char) (A)[0])))
 
470
#define sint4korr(A)    (*((long *) (A)))
 
471
#define uint2korr(A)    (*((uint16_t *) (A)))
472
472
#if defined(HAVE_purify)
473
 
#define uint3korr(A)  (uint32_t) (((uint32_t) ((unsigned char) (A)[0])) + \
474
 
                                    (((uint32_t) ((unsigned char) (A)[1])) << 8) + \
475
 
                                    (((uint32_t) ((unsigned char) (A)[2])) << 16))
 
473
#define uint3korr(A)    (uint32_t) (((uint32_t) ((unsigned char) (A)[0])) +\
 
474
                                  (((uint32_t) ((unsigned char) (A)[1])) << 8) +\
 
475
                                  (((uint32_t) ((unsigned char) (A)[2])) << 16))
476
476
#else
477
477
/*
478
 
  ATTENTION !
479
 
 
480
 
  Please, note, uint3korr reads 4 bytes (not 3) !
481
 
  It means, that you have to provide enough allocated space !
 
478
   ATTENTION !
 
479
   
 
480
    Please, note, uint3korr reads 4 bytes (not 3) !
 
481
    It means, that you have to provide enough allocated space !
482
482
*/
483
 
#define uint3korr(A)  (long) (*((unsigned int *) (A)) & 0xFFFFFF)
 
483
#define uint3korr(A)    (long) (*((unsigned int *) (A)) & 0xFFFFFF)
484
484
#endif /* HAVE_purify */
485
 
#define uint4korr(A)  (*((uint32_t *) (A)))
486
 
#define uint5korr(A)  ((uint64_t)(((uint32_t) ((unsigned char) (A)[0])) + \
487
 
                                    (((uint32_t) ((unsigned char) (A)[1])) << 8) + \
488
 
                                    (((uint32_t) ((unsigned char) (A)[2])) << 16) + \
489
 
                                    (((uint32_t) ((unsigned char) (A)[3])) << 24)) + \
490
 
                         (((uint64_t) ((unsigned char) (A)[4])) << 32))
491
 
#define uint6korr(A)  ((uint64_t)(((uint32_t)    ((unsigned char) (A)[0]))          + \
492
 
                                    (((uint32_t)    ((unsigned char) (A)[1])) << 8)   + \
493
 
                                    (((uint32_t)    ((unsigned char) (A)[2])) << 16)  + \
494
 
                                    (((uint32_t)    ((unsigned char) (A)[3])) << 24)) + \
495
 
                         (((uint64_t) ((unsigned char) (A)[4])) << 32) + \
 
485
#define uint4korr(A)    (*((uint32_t *) (A)))
 
486
#define uint5korr(A)    ((uint64_t)(((uint32_t) ((unsigned char) (A)[0])) +\
 
487
                                    (((uint32_t) ((unsigned char) (A)[1])) << 8) +\
 
488
                                    (((uint32_t) ((unsigned char) (A)[2])) << 16) +\
 
489
                                    (((uint32_t) ((unsigned char) (A)[3])) << 24)) +\
 
490
                                    (((uint64_t) ((unsigned char) (A)[4])) << 32))
 
491
#define uint6korr(A)    ((uint64_t)(((uint32_t)    ((unsigned char) (A)[0]))          + \
 
492
                                     (((uint32_t)    ((unsigned char) (A)[1])) << 8)   + \
 
493
                                     (((uint32_t)    ((unsigned char) (A)[2])) << 16)  + \
 
494
                                     (((uint32_t)    ((unsigned char) (A)[3])) << 24)) + \
 
495
                         (((uint64_t) ((unsigned char) (A)[4])) << 32) +       \
496
496
                         (((uint64_t) ((unsigned char) (A)[5])) << 40))
497
 
#define uint8korr(A)  (*((uint64_t *) (A)))
498
 
#define sint8korr(A)  (*((int64_t *) (A)))
499
 
#define int2store(T,A)  *((uint16_t*) (T))= (uint16_t) (A)
500
 
#define int3store(T,A)  do { *(T)=  (unsigned char) ((A));              \
501
 
    *(T+1)=(unsigned char) (((uint32_t) (A) >> 8));                     \
502
 
    *(T+2)=(unsigned char) (((A) >> 16)); } while (0)
503
 
#define int4store(T,A)  *((long *) (T))= (long) (A)
504
 
#define int5store(T,A)  do { *(T)= (unsigned char)((A));                \
505
 
    *((T)+1)=(unsigned char) (((A) >> 8));                              \
506
 
    *((T)+2)=(unsigned char) (((A) >> 16));                             \
507
 
    *((T)+3)=(unsigned char) (((A) >> 24));                             \
508
 
    *((T)+4)=(unsigned char) (((A) >> 32)); } while(0)
 
497
#define uint8korr(A)    (*((uint64_t *) (A)))
 
498
#define sint8korr(A)    (*((int64_t *) (A)))
 
499
#define int2store(T,A)  *((uint16_t*) (T))= (uint16_t) (A)
 
500
#define int3store(T,A)  do { *(T)=  (unsigned char) ((A));\
 
501
                            *(T+1)=(unsigned char) (((uint32_t) (A) >> 8));\
 
502
                            *(T+2)=(unsigned char) (((A) >> 16)); } while (0)
 
503
#define int4store(T,A)  *((long *) (T))= (long) (A)
 
504
#define int5store(T,A)  do { *(T)= (unsigned char)((A));\
 
505
                             *((T)+1)=(unsigned char) (((A) >> 8));\
 
506
                             *((T)+2)=(unsigned char) (((A) >> 16));\
 
507
                             *((T)+3)=(unsigned char) (((A) >> 24)); \
 
508
                             *((T)+4)=(unsigned char) (((A) >> 32)); } while(0)
509
509
#define int6store(T,A)  do { *(T)=    (unsigned char)((A));          \
510
 
    *((T)+1)=(unsigned char) (((A) >> 8));                           \
511
 
    *((T)+2)=(unsigned char) (((A) >> 16));                          \
512
 
    *((T)+3)=(unsigned char) (((A) >> 24));                          \
513
 
    *((T)+4)=(unsigned char) (((A) >> 32));                             \
514
 
    *((T)+5)=(unsigned char) (((A) >> 40)); } while(0)
515
 
#define int8store(T,A)  *((uint64_t *) (T))= (uint64_t) (A)
 
510
                             *((T)+1)=(unsigned char) (((A) >> 8));  \
 
511
                             *((T)+2)=(unsigned char) (((A) >> 16)); \
 
512
                             *((T)+3)=(unsigned char) (((A) >> 24)); \
 
513
                             *((T)+4)=(unsigned char) (((A) >> 32)); \
 
514
                             *((T)+5)=(unsigned char) (((A) >> 40)); } while(0)
 
515
#define int8store(T,A)  *((uint64_t *) (T))= (uint64_t) (A)
516
516
 
517
 
  typedef union {
518
 
    double v;
519
 
    long m[2];
520
 
  } doubleget_union;
521
 
#define doubleget(V,M)     \
522
 
  do { doubleget_union _tmp;    \
523
 
    _tmp.m[0] = *((long*)(M));       \
524
 
    _tmp.m[1] = *(((long*) (M))+1);  \
525
 
    (V) = _tmp.v; } while(0)
 
517
typedef union {
 
518
  double v;
 
519
  long m[2];
 
520
} doubleget_union;
 
521
#define doubleget(V,M)  \
 
522
do { doubleget_union _tmp; \
 
523
     _tmp.m[0] = *((long*)(M)); \
 
524
     _tmp.m[1] = *(((long*) (M))+1); \
 
525
     (V) = _tmp.v; } while(0)
526
526
#define doublestore(T,V) do { *((long *) T) = ((doubleget_union *)&V)->m[0]; \
527
 
    *(((long *) T)+1) = ((doubleget_union *)&V)->m[1];                  \
528
 
  } while (0)
 
527
                             *(((long *) T)+1) = ((doubleget_union *)&V)->m[1]; \
 
528
                         } while (0)
529
529
#define float4get(V,M)   do { *((float *) &(V)) = *((float*) (M)); } while(0)
530
530
#define float8get(V,M)   doubleget((V),(M))
531
531
#define float4store(V,M) memcpy(V, (&M), sizeof(float))
538
538
  We're here if it's not a IA-32 architecture (Win32 and UNIX IA-32 defines
539
539
  were done before)
540
540
*/
541
 
#define sint2korr(A)  (int16_t) (((int16_t) ((unsigned char) (A)[0])) + \
542
 
                                   ((int16_t) ((int16_t) (A)[1]) << 8))
543
 
#define sint3korr(A)  ((int32_t) ((((unsigned char) (A)[2]) & 128) ?  \
544
 
                                    (((uint32_t) 255L << 24) |          \
545
 
                                     (((uint32_t) (unsigned char) (A)[2]) << 16) | \
546
 
                                     (((uint32_t) (unsigned char) (A)[1]) << 8) | \
547
 
                                     ((uint32_t) (unsigned char) (A)[0])) : \
548
 
                                    (((uint32_t) (unsigned char) (A)[2]) << 16) | \
549
 
                                    (((uint32_t) (unsigned char) (A)[1]) << 8) | \
550
 
                                    ((uint32_t) (unsigned char) (A)[0])))
551
 
#define sint4korr(A)  (int32_t) (((int32_t) ((unsigned char) (A)[0])) + \
552
 
                                   (((int32_t) ((unsigned char) (A)[1]) << 8)) + \
553
 
                                   (((int32_t) ((unsigned char) (A)[2]) << 16)) + \
554
 
                                   (((int32_t) ((int16_t) (A)[3]) << 24)))
555
 
#define sint8korr(A)  (int64_t) uint8korr(A)
556
 
#define uint2korr(A)  (uint16_t) (((uint16_t) ((unsigned char) (A)[0])) + \
557
 
                                    ((uint16_t) ((unsigned char) (A)[1]) << 8))
558
 
#define uint3korr(A)  (uint32_t) (((uint32_t) ((unsigned char) (A)[0])) + \
559
 
                                    (((uint32_t) ((unsigned char) (A)[1])) << 8) + \
560
 
                                    (((uint32_t) ((unsigned char) (A)[2])) << 16))
561
 
#define uint4korr(A)  (uint32_t) (((uint32_t) ((unsigned char) (A)[0])) + \
562
 
                                    (((uint32_t) ((unsigned char) (A)[1])) << 8) + \
563
 
                                    (((uint32_t) ((unsigned char) (A)[2])) << 16) + \
564
 
                                    (((uint32_t) ((unsigned char) (A)[3])) << 24))
565
 
#define uint5korr(A)  ((uint64_t)(((uint32_t) ((unsigned char) (A)[0])) + \
566
 
                                    (((uint32_t) ((unsigned char) (A)[1])) << 8) + \
567
 
                                    (((uint32_t) ((unsigned char) (A)[2])) << 16) + \
568
 
                                    (((uint32_t) ((unsigned char) (A)[3])) << 24)) + \
569
 
                         (((uint64_t) ((unsigned char) (A)[4])) << 32))
570
 
#define uint6korr(A)  ((uint64_t)(((uint32_t)    ((unsigned char) (A)[0]))          + \
571
 
                                    (((uint32_t)    ((unsigned char) (A)[1])) << 8)   + \
572
 
                                    (((uint32_t)    ((unsigned char) (A)[2])) << 16)  + \
573
 
                                    (((uint32_t)    ((unsigned char) (A)[3])) << 24)) + \
574
 
                         (((uint64_t) ((unsigned char) (A)[4])) << 32) + \
 
541
#define sint2korr(A)    (int16_t) (((int16_t) ((unsigned char) (A)[0])) +\
 
542
                                 ((int16_t) ((int16_t) (A)[1]) << 8))
 
543
#define sint3korr(A)    ((int32_t) ((((unsigned char) (A)[2]) & 128) ? \
 
544
                                  (((uint32_t) 255L << 24) | \
 
545
                                   (((uint32_t) (unsigned char) (A)[2]) << 16) |\
 
546
                                   (((uint32_t) (unsigned char) (A)[1]) << 8) | \
 
547
                                   ((uint32_t) (unsigned char) (A)[0])) : \
 
548
                                  (((uint32_t) (unsigned char) (A)[2]) << 16) |\
 
549
                                  (((uint32_t) (unsigned char) (A)[1]) << 8) | \
 
550
                                  ((uint32_t) (unsigned char) (A)[0])))
 
551
#define sint4korr(A)    (int32_t) (((int32_t) ((unsigned char) (A)[0])) +\
 
552
                                (((int32_t) ((unsigned char) (A)[1]) << 8)) +\
 
553
                                (((int32_t) ((unsigned char) (A)[2]) << 16)) +\
 
554
                                (((int32_t) ((int16_t) (A)[3]) << 24)))
 
555
#define sint8korr(A)    (int64_t) uint8korr(A)
 
556
#define uint2korr(A)    (uint16_t) (((uint16_t) ((unsigned char) (A)[0])) +\
 
557
                                  ((uint16_t) ((unsigned char) (A)[1]) << 8))
 
558
#define uint3korr(A)    (uint32_t) (((uint32_t) ((unsigned char) (A)[0])) +\
 
559
                                  (((uint32_t) ((unsigned char) (A)[1])) << 8) +\
 
560
                                  (((uint32_t) ((unsigned char) (A)[2])) << 16))
 
561
#define uint4korr(A)    (uint32_t) (((uint32_t) ((unsigned char) (A)[0])) +\
 
562
                                  (((uint32_t) ((unsigned char) (A)[1])) << 8) +\
 
563
                                  (((uint32_t) ((unsigned char) (A)[2])) << 16) +\
 
564
                                  (((uint32_t) ((unsigned char) (A)[3])) << 24))
 
565
#define uint5korr(A)    ((uint64_t)(((uint32_t) ((unsigned char) (A)[0])) +\
 
566
                                    (((uint32_t) ((unsigned char) (A)[1])) << 8) +\
 
567
                                    (((uint32_t) ((unsigned char) (A)[2])) << 16) +\
 
568
                                    (((uint32_t) ((unsigned char) (A)[3])) << 24)) +\
 
569
                                    (((uint64_t) ((unsigned char) (A)[4])) << 32))
 
570
#define uint6korr(A)    ((uint64_t)(((uint32_t)    ((unsigned char) (A)[0]))          + \
 
571
                                     (((uint32_t)    ((unsigned char) (A)[1])) << 8)   + \
 
572
                                     (((uint32_t)    ((unsigned char) (A)[2])) << 16)  + \
 
573
                                     (((uint32_t)    ((unsigned char) (A)[3])) << 24)) + \
 
574
                         (((uint64_t) ((unsigned char) (A)[4])) << 32) +       \
575
575
                         (((uint64_t) ((unsigned char) (A)[5])) << 40))
576
 
#define uint8korr(A)  ((uint64_t)(((uint32_t) ((unsigned char) (A)[0])) + \
577
 
                                    (((uint32_t) ((unsigned char) (A)[1])) << 8) + \
578
 
                                    (((uint32_t) ((unsigned char) (A)[2])) << 16) + \
579
 
                                    (((uint32_t) ((unsigned char) (A)[3])) << 24)) + \
580
 
                         (((uint64_t) (((uint32_t) ((unsigned char) (A)[4])) + \
581
 
                                       (((uint32_t) ((unsigned char) (A)[5])) << 8) + \
582
 
                                       (((uint32_t) ((unsigned char) (A)[6])) << 16) + \
583
 
                                       (((uint32_t) ((unsigned char) (A)[7])) << 24))) << \
584
 
                          32))
585
 
#define int2store(T,A)       do { uint32_t def_temp= (uint32_t) (A) ;   \
586
 
    *((unsigned char*) (T))=  (unsigned char)(def_temp);                \
587
 
    *((unsigned char*) (T)+1)=(unsigned char)((def_temp >> 8));         \
588
 
  } while(0)
589
 
#define int3store(T,A)       do { /*lint -save -e734 */                 \
590
 
    *((unsigned char*)(T))=(unsigned char) ((A));                       \
591
 
    *((unsigned char*) (T)+1)=(unsigned char) (((A) >> 8));             \
592
 
    *((unsigned char*)(T)+2)=(unsigned char) (((A) >> 16));             \
593
 
    /*lint -restore */} while(0)
594
 
#define int4store(T,A)       do { *((char *)(T))=(char) ((A));          \
595
 
    *(((char *)(T))+1)=(char) (((A) >> 8));                             \
596
 
    *(((char *)(T))+2)=(char) (((A) >> 16));                            \
597
 
    *(((char *)(T))+3)=(char) (((A) >> 24)); } while(0)
598
 
#define int5store(T,A)       do { *((char *)(T))=     (char)((A));      \
599
 
    *(((char *)(T))+1)= (char)(((A) >> 8));                             \
600
 
    *(((char *)(T))+2)= (char)(((A) >> 16));                            \
601
 
    *(((char *)(T))+3)= (char)(((A) >> 24));                            \
602
 
    *(((char *)(T))+4)= (char)(((A) >> 32));                            \
603
 
  } while(0)
604
 
#define int6store(T,A)       do { *((char *)(T))=     (char)((A));      \
605
 
    *(((char *)(T))+1)= (char)(((A) >> 8));                             \
606
 
    *(((char *)(T))+2)= (char)(((A) >> 16));                            \
607
 
    *(((char *)(T))+3)= (char)(((A) >> 24));                            \
608
 
    *(((char *)(T))+4)= (char)(((A) >> 32));                            \
609
 
    *(((char *)(T))+5)= (char)(((A) >> 40));                            \
610
 
  } while(0)
 
576
#define uint8korr(A)    ((uint64_t)(((uint32_t) ((unsigned char) (A)[0])) +\
 
577
                                    (((uint32_t) ((unsigned char) (A)[1])) << 8) +\
 
578
                                    (((uint32_t) ((unsigned char) (A)[2])) << 16) +\
 
579
                                    (((uint32_t) ((unsigned char) (A)[3])) << 24)) +\
 
580
                        (((uint64_t) (((uint32_t) ((unsigned char) (A)[4])) +\
 
581
                                    (((uint32_t) ((unsigned char) (A)[5])) << 8) +\
 
582
                                    (((uint32_t) ((unsigned char) (A)[6])) << 16) +\
 
583
                                    (((uint32_t) ((unsigned char) (A)[7])) << 24))) <<\
 
584
                                    32))
 
585
#define int2store(T,A)       do { uint32_t def_temp= (uint32_t) (A) ;\
 
586
                                  *((unsigned char*) (T))=  (unsigned char)(def_temp); \
 
587
                                   *((unsigned char*) (T)+1)=(unsigned char)((def_temp >> 8)); \
 
588
                             } while(0)
 
589
#define int3store(T,A)       do { /*lint -save -e734 */\
 
590
                                  *((unsigned char*)(T))=(unsigned char) ((A));\
 
591
                                  *((unsigned char*) (T)+1)=(unsigned char) (((A) >> 8));\
 
592
                                  *((unsigned char*)(T)+2)=(unsigned char) (((A) >> 16)); \
 
593
                                  /*lint -restore */} while(0)
 
594
#define int4store(T,A)       do { *((char *)(T))=(char) ((A));\
 
595
                                  *(((char *)(T))+1)=(char) (((A) >> 8));\
 
596
                                  *(((char *)(T))+2)=(char) (((A) >> 16));\
 
597
                                  *(((char *)(T))+3)=(char) (((A) >> 24)); } while(0)
 
598
#define int5store(T,A)       do { *((char *)(T))=     (char)((A));  \
 
599
                                  *(((char *)(T))+1)= (char)(((A) >> 8)); \
 
600
                                  *(((char *)(T))+2)= (char)(((A) >> 16)); \
 
601
                                  *(((char *)(T))+3)= (char)(((A) >> 24)); \
 
602
                                  *(((char *)(T))+4)= (char)(((A) >> 32)); \
 
603
                                } while(0)
 
604
#define int6store(T,A)       do { *((char *)(T))=     (char)((A)); \
 
605
                                  *(((char *)(T))+1)= (char)(((A) >> 8)); \
 
606
                                  *(((char *)(T))+2)= (char)(((A) >> 16)); \
 
607
                                  *(((char *)(T))+3)= (char)(((A) >> 24)); \
 
608
                                  *(((char *)(T))+4)= (char)(((A) >> 32)); \
 
609
                                  *(((char *)(T))+5)= (char)(((A) >> 40)); \
 
610
                                } while(0)
611
611
#define int8store(T,A)       do { uint32_t def_temp= (uint32_t) (A), def_temp2= (uint32_t) ((A) >> 32); \
612
 
    int4store((T),def_temp);                                            \
613
 
    int4store((T+4),def_temp2); } while(0)
 
612
                                  int4store((T),def_temp); \
 
613
                                  int4store((T+4),def_temp2); } while(0)
614
614
#ifdef WORDS_BIGENDIAN
615
 
#define float4store(T,A) do { *(T)= ((unsigned char *) &A)[3];          \
616
 
    *((T)+1)=(char) ((unsigned char *) &A)[2];                          \
617
 
    *((T)+2)=(char) ((unsigned char *) &A)[1];                          \
618
 
    *((T)+3)=(char) ((unsigned char *) &A)[0]; } while(0)
619
 
 
620
 
#define float4get(V,M)   do { float def_temp;                           \
621
 
    ((unsigned char*) &def_temp)[0]=(M)[3];                             \
622
 
    ((unsigned char*) &def_temp)[1]=(M)[2];                             \
623
 
    ((unsigned char*) &def_temp)[2]=(M)[1];                             \
624
 
    ((unsigned char*) &def_temp)[3]=(M)[0];                             \
625
 
    (V)=def_temp; } while(0)
626
 
#define float8store(T,V) do { *(T)= ((unsigned char *) &V)[7];          \
627
 
    *((T)+1)=(char) ((unsigned char *) &V)[6];                          \
628
 
    *((T)+2)=(char) ((unsigned char *) &V)[5];                          \
629
 
    *((T)+3)=(char) ((unsigned char *) &V)[4];                          \
630
 
    *((T)+4)=(char) ((unsigned char *) &V)[3];                          \
631
 
    *((T)+5)=(char) ((unsigned char *) &V)[2];                          \
632
 
    *((T)+6)=(char) ((unsigned char *) &V)[1];                          \
633
 
    *((T)+7)=(char) ((unsigned char *) &V)[0]; } while(0)
634
 
 
635
 
#define float8get(V,M)   do { double def_temp;                          \
636
 
    ((unsigned char*) &def_temp)[0]=(M)[7];                             \
637
 
    ((unsigned char*) &def_temp)[1]=(M)[6];                             \
638
 
    ((unsigned char*) &def_temp)[2]=(M)[5];                             \
639
 
    ((unsigned char*) &def_temp)[3]=(M)[4];                             \
640
 
    ((unsigned char*) &def_temp)[4]=(M)[3];                             \
641
 
    ((unsigned char*) &def_temp)[5]=(M)[2];                             \
642
 
    ((unsigned char*) &def_temp)[6]=(M)[1];                             \
643
 
    ((unsigned char*) &def_temp)[7]=(M)[0];                             \
644
 
    (V) = def_temp; } while(0)
 
615
#define float4store(T,A) do { *(T)= ((unsigned char *) &A)[3];\
 
616
                              *((T)+1)=(char) ((unsigned char *) &A)[2];\
 
617
                              *((T)+2)=(char) ((unsigned char *) &A)[1];\
 
618
                              *((T)+3)=(char) ((unsigned char *) &A)[0]; } while(0)
 
619
 
 
620
#define float4get(V,M)   do { float def_temp;\
 
621
                              ((unsigned char*) &def_temp)[0]=(M)[3];\
 
622
                              ((unsigned char*) &def_temp)[1]=(M)[2];\
 
623
                              ((unsigned char*) &def_temp)[2]=(M)[1];\
 
624
                              ((unsigned char*) &def_temp)[3]=(M)[0];\
 
625
                              (V)=def_temp; } while(0)
 
626
#define float8store(T,V) do { *(T)= ((unsigned char *) &V)[7];\
 
627
                              *((T)+1)=(char) ((unsigned char *) &V)[6];\
 
628
                              *((T)+2)=(char) ((unsigned char *) &V)[5];\
 
629
                              *((T)+3)=(char) ((unsigned char *) &V)[4];\
 
630
                              *((T)+4)=(char) ((unsigned char *) &V)[3];\
 
631
                              *((T)+5)=(char) ((unsigned char *) &V)[2];\
 
632
                              *((T)+6)=(char) ((unsigned char *) &V)[1];\
 
633
                              *((T)+7)=(char) ((unsigned char *) &V)[0]; } while(0)
 
634
 
 
635
#define float8get(V,M)   do { double def_temp;\
 
636
                              ((unsigned char*) &def_temp)[0]=(M)[7];\
 
637
                              ((unsigned char*) &def_temp)[1]=(M)[6];\
 
638
                              ((unsigned char*) &def_temp)[2]=(M)[5];\
 
639
                              ((unsigned char*) &def_temp)[3]=(M)[4];\
 
640
                              ((unsigned char*) &def_temp)[4]=(M)[3];\
 
641
                              ((unsigned char*) &def_temp)[5]=(M)[2];\
 
642
                              ((unsigned char*) &def_temp)[6]=(M)[1];\
 
643
                              ((unsigned char*) &def_temp)[7]=(M)[0];\
 
644
                              (V) = def_temp; } while(0)
645
645
#else
646
646
#define float4get(V,M)   memcpy(&V, (M), sizeof(float))
647
647
#define float4store(V,M) memcpy(V, (&M), sizeof(float))
648
648
 
649
649
#if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN)
650
 
#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((unsigned char *) &V)[4]; \
651
 
    *(((char*)T)+1)=(char) ((unsigned char *) &V)[5];                   \
652
 
    *(((char*)T)+2)=(char) ((unsigned char *) &V)[6];                   \
653
 
    *(((char*)T)+3)=(char) ((unsigned char *) &V)[7];                   \
654
 
    *(((char*)T)+4)=(char) ((unsigned char *) &V)[0];                   \
655
 
    *(((char*)T)+5)=(char) ((unsigned char *) &V)[1];                   \
656
 
    *(((char*)T)+6)=(char) ((unsigned char *) &V)[2];                   \
657
 
    *(((char*)T)+7)=(char) ((unsigned char *) &V)[3]; }                 \
658
 
  while(0)
659
 
#define doubleget(V,M)   do { double def_temp;                          \
660
 
    ((unsigned char*) &def_temp)[0]=(M)[4];                             \
661
 
    ((unsigned char*) &def_temp)[1]=(M)[5];                             \
662
 
    ((unsigned char*) &def_temp)[2]=(M)[6];                             \
663
 
    ((unsigned char*) &def_temp)[3]=(M)[7];                             \
664
 
    ((unsigned char*) &def_temp)[4]=(M)[0];                             \
665
 
    ((unsigned char*) &def_temp)[5]=(M)[1];                             \
666
 
    ((unsigned char*) &def_temp)[6]=(M)[2];                             \
667
 
    ((unsigned char*) &def_temp)[7]=(M)[3];                             \
668
 
    (V) = def_temp; } while(0)
 
650
#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((unsigned char *) &V)[4];\
 
651
                              *(((char*)T)+1)=(char) ((unsigned char *) &V)[5];\
 
652
                              *(((char*)T)+2)=(char) ((unsigned char *) &V)[6];\
 
653
                              *(((char*)T)+3)=(char) ((unsigned char *) &V)[7];\
 
654
                              *(((char*)T)+4)=(char) ((unsigned char *) &V)[0];\
 
655
                              *(((char*)T)+5)=(char) ((unsigned char *) &V)[1];\
 
656
                              *(((char*)T)+6)=(char) ((unsigned char *) &V)[2];\
 
657
                              *(((char*)T)+7)=(char) ((unsigned char *) &V)[3]; }\
 
658
                         while(0)
 
659
#define doubleget(V,M)   do { double def_temp;\
 
660
                              ((unsigned char*) &def_temp)[0]=(M)[4];\
 
661
                              ((unsigned char*) &def_temp)[1]=(M)[5];\
 
662
                              ((unsigned char*) &def_temp)[2]=(M)[6];\
 
663
                              ((unsigned char*) &def_temp)[3]=(M)[7];\
 
664
                              ((unsigned char*) &def_temp)[4]=(M)[0];\
 
665
                              ((unsigned char*) &def_temp)[5]=(M)[1];\
 
666
                              ((unsigned char*) &def_temp)[6]=(M)[2];\
 
667
                              ((unsigned char*) &def_temp)[7]=(M)[3];\
 
668
                              (V) = def_temp; } while(0)
669
669
#endif /* __FLOAT_WORD_ORDER */
670
670
 
671
671
#define float8get(V,M)   doubleget((V),(M))
678
678
  Macro for reading 32-bit integer from network byte order (big-endian)
679
679
  from unaligned memory location.
680
680
*/
681
 
#define int4net(A)        (int32_t) (((uint32_t) ((unsigned char) (A)[3]))        | \
682
 
                                     (((uint32_t) ((unsigned char) (A)[2])) << 8)  | \
683
 
                                     (((uint32_t) ((unsigned char) (A)[1])) << 16) | \
684
 
                                     (((uint32_t) ((unsigned char) (A)[0])) << 24))
 
681
#define int4net(A)        (int32_t) (((uint32_t) ((unsigned char) (A)[3]))        |\
 
682
                                  (((uint32_t) ((unsigned char) (A)[2])) << 8)  |\
 
683
                                  (((uint32_t) ((unsigned char) (A)[1])) << 16) |\
 
684
                                  (((uint32_t) ((unsigned char) (A)[0])) << 24))
685
685
/*
686
686
  Define-funktions for reading and storing in machine format from/to
687
687
  short/long to/from some place in memory V should be a (not
690
690
 
691
691
#ifdef WORDS_BIGENDIAN
692
692
 
693
 
#define ushortget(V,M)  do { V = (uint16_t) (((uint16_t) ((unsigned char) (M)[1]))+ \
694
 
                                             ((uint16_t) ((uint16_t) (M)[0]) << 8)); } while(0)
695
 
#define shortget(V,M)   do { V = (short) (((short) ((unsigned char) (M)[1]))+ \
696
 
                                          ((short) ((short) (M)[0]) << 8)); } while(0)
697
 
#define longget(V,M)    do { int32_t def_temp;                          \
698
 
    ((unsigned char*) &def_temp)[0]=(M)[0];                             \
699
 
    ((unsigned char*) &def_temp)[1]=(M)[1];                             \
700
 
    ((unsigned char*) &def_temp)[2]=(M)[2];                             \
701
 
    ((unsigned char*) &def_temp)[3]=(M)[3];                             \
702
 
    (V)=def_temp; } while(0)
703
 
#define ulongget(V,M)   do { uint32_t def_temp;                         \
704
 
    ((unsigned char*) &def_temp)[0]=(M)[0];                             \
705
 
    ((unsigned char*) &def_temp)[1]=(M)[1];                             \
706
 
    ((unsigned char*) &def_temp)[2]=(M)[2];                             \
707
 
    ((unsigned char*) &def_temp)[3]=(M)[3];                             \
708
 
    (V)=def_temp; } while(0)
709
 
#define shortstore(T,A) do { uint32_t def_temp=(uint32_t) (A) ; \
710
 
    *(((char*)T)+1)=(char)(def_temp);                                   \
711
 
    *(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
712
 
#define longstore(T,A)  do { *(((char*)T)+3)=((A));             \
713
 
    *(((char*)T)+2)=(((A) >> 8));                               \
714
 
    *(((char*)T)+1)=(((A) >> 16));                                      \
715
 
    *(((char*)T)+0)=(((A) >> 24)); } while(0)
 
693
#define ushortget(V,M)  do { V = (uint16_t) (((uint16_t) ((unsigned char) (M)[1]))+\
 
694
                                 ((uint16_t) ((uint16_t) (M)[0]) << 8)); } while(0)
 
695
#define shortget(V,M)   do { V = (short) (((short) ((unsigned char) (M)[1]))+\
 
696
                                 ((short) ((short) (M)[0]) << 8)); } while(0)
 
697
#define longget(V,M)    do { int32_t def_temp;\
 
698
                             ((unsigned char*) &def_temp)[0]=(M)[0];\
 
699
                             ((unsigned char*) &def_temp)[1]=(M)[1];\
 
700
                             ((unsigned char*) &def_temp)[2]=(M)[2];\
 
701
                             ((unsigned char*) &def_temp)[3]=(M)[3];\
 
702
                             (V)=def_temp; } while(0)
 
703
#define ulongget(V,M)   do { uint32_t def_temp;\
 
704
                            ((unsigned char*) &def_temp)[0]=(M)[0];\
 
705
                            ((unsigned char*) &def_temp)[1]=(M)[1];\
 
706
                            ((unsigned char*) &def_temp)[2]=(M)[2];\
 
707
                            ((unsigned char*) &def_temp)[3]=(M)[3];\
 
708
                            (V)=def_temp; } while(0)
 
709
#define shortstore(T,A) do { uint32_t def_temp=(uint32_t) (A) ;\
 
710
                             *(((char*)T)+1)=(char)(def_temp); \
 
711
                             *(((char*)T)+0)=(char)(def_temp >> 8); } while(0)
 
712
#define longstore(T,A)  do { *(((char*)T)+3)=((A));\
 
713
                             *(((char*)T)+2)=(((A) >> 8));\
 
714
                             *(((char*)T)+1)=(((A) >> 16));\
 
715
                             *(((char*)T)+0)=(((A) >> 24)); } while(0)
716
716
 
717
717
#define floatget(V,M)     memcpy(&V, (M), sizeof(float))
718
718
#define floatstore(T, V)   memcpy((T), (&V), sizeof(float))
719
 
#define doubleget(V, M)    memcpy(&V, (M), sizeof(double))
 
719
#define doubleget(V, M)   memcpy(&V, (M), sizeof(double))
720
720
#define doublestore(T, V)  memcpy((T), &V, sizeof(double))
721
721
#define int64_tget(V, M)   memcpy(&V, (M), sizeof(uint64_t))
722
722
#define int64_tstore(T, V) memcpy((T), &V, sizeof(uint64_t))
723
723
 
724
724
#else
725
725
 
726
 
#define ushortget(V,M)  do { V = uint2korr(M); } while(0)
727
 
#define shortget(V,M)  do { V = sint2korr(M); } while(0)
728
 
#define longget(V,M)  do { V = sint4korr(M); } while(0)
 
726
#define ushortget(V,M)  do { V = uint2korr(M); } while(0)
 
727
#define shortget(V,M)   do { V = sint2korr(M); } while(0)
 
728
#define longget(V,M)    do { V = sint4korr(M); } while(0)
729
729
#define ulongget(V,M)   do { V = uint4korr(M); } while(0)
730
730
#define shortstore(T,V) int2store(T,V)
731
 
#define longstore(T,V)  int4store(T,V)
 
731
#define longstore(T,V)  int4store(T,V)
732
732
#ifndef floatstore
733
733
#define floatstore(T,V)   memcpy((T), (&V), sizeof(float))
734
734
#define floatget(V,M)     memcpy(&V, (M), sizeof(float))
735
735
#endif
736
736
#ifndef doubleget
737
 
#define doubleget(V, M)   memcpy(&V, (M), sizeof(double))
 
737
#define doubleget(V, M)   memcpy(&V, (M), sizeof(double))
738
738
#define doublestore(T,V)  memcpy((T), &V, sizeof(double))
739
739
#endif /* doubleget */
740
740
#define int64_tget(V,M)   memcpy(&V, (M), sizeof(uint64_t))