root/src/dps8/dps8.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * vim: filetype=c:tabstop=4:ai:expandtab
   3  * SPDX-License-Identifier: ICU
   4  * scspell-id: 6965b612-f62e-11ec-a432-80ee73e9b8e7
   5  *
   6  * ---------------------------------------------------------------------------
   7  *
   8  * Copyright (c) 2012-2016 Harry Reed
   9  * Copyright (c) 2012 Dave Jordan
  10  * Copyright (c) 2013-2018 Charles Anthony
  11  * Copyright (c) 2016 Jean-Michel Merliot
  12  * Copyright (c) 2021-2024 The DPS8M Development Team
  13  *
  14  * This software is made available under the terms of the ICU License.
  15  * See the LICENSE.md file at the top-level directory of this distribution.
  16  *
  17  * ---------------------------------------------------------------------------
  18  */
  19 
  20 #if !defined(DPS8_H)
  21 # define DPS8_H
  22 
  23 # if defined(__FAST_MATH__)
  24 #  error __FAST_MATH__ is unsupported
  25 # endif /* if defined(__FAST_MATH__) */
  26 
  27 # include <stdio.h>
  28 # include <stdbool.h>
  29 # include <stdatomic.h>
  30 # include <errno.h>
  31 # include <inttypes.h>
  32 # include <sys/stat.h>
  33 # include <sys/time.h>
  34 # include <setjmp.h>  // for setjmp/longjmp used by interrupts & faults
  35 
  36 # if (defined(__APPLE__) && defined(__MACH__)) || defined(__ANDROID__)
  37 #  include <libgen.h>  // needed for macOS and Android
  38 # endif
  39 
  40 # include "sir.h"
  41 # include "sir/platform.h"
  42 # include "sir/internal.h"
  43 
  44 # if defined(_M_X64) || defined(_M_AMD64) || defined(__amd64__) || defined(__x86_64__) || defined(__AMD64) || \
  45      defined(_M_IX86) || defined(__i386) || defined(__i486) || defined(__i586) || defined(__i686) || defined(__ix86)
  46 #  if HAS_INCLUDE(<immintrin.h>)
  47 #   include <immintrin.h>
  48 #  endif
  49 # endif
  50 
  51 # undef HAS_ATTRIBUTE
  52 # if defined __has_attribute && (defined(__clang__) || defined(__GNUC__))
  53 #  define HAS_ATTRIBUTE(atr) __has_attribute(atr)
  54 # else
  55 #  define HAS_ATTRIBUTE(atr) 0
  56 # endif
  57 
  58 # undef HOT
  59 # if HAS_ATTRIBUTE(hot)
  60 #  define HOT __attribute__((hot))
  61 # endif
  62 # if !defined(HOT)
  63 #  define HOT
  64 # endif
  65 
  66 # undef HAS_BUILTIN
  67 # if defined __has_builtin
  68 #  define HAS_BUILTIN(builtin) __has_builtin(builtin)
  69 # else
  70 #  define HAS_BUILTIN(builtin) 0
  71 # endif
  72 
  73 # if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__ANDROID__) || defined(_AIX)
  74 #  undef setjmp
  75 #  define setjmp _setjmp
  76 #  undef longjmp
  77 #  define longjmp _longjmp
  78 # endif
  79 
  80 typedef int64_t __int64_t;
  81 
  82 # if defined(NEED_128)
  83 typedef struct { uint64_t h; uint64_t l; } x__uint128_t;
  84 typedef struct { int64_t h;  uint64_t l; } x__int128_t;
  85 #  define construct_128(h, l) ((uint128) { (h), (l) })
  86 #  define construct_s128(h, l) ((int128) { (h), (l) })
  87 # endif /* if defined(NEED_128) */
  88 
  89 // Quiet compiler unused warnings
  90 # define QUIET_UNUSED
  91 
  92 // Enable speed over debugging if not TESTING
  93 # if !defined(TESTING)
  94 #  define SPEED
  95 # endif /* if !defined(TESTING) */
  96 
  97 // Experimental dial_out line disconnect delay
  98 // FNP polled ~100Hz; 2 secs. is 200 polls
  99 # define DISC_DELAY 200
 100 
 101 // Micro-cache
 102 # if !defined(NO_UCACHE)
 103 #  undef OLDAPP
 104 # else
 105 #  define OLDAPP
 106 # endif /* if !defined(NO_UCACHE) */
 107 # if !defined(OLDAPP)
 108 #  if !defined(UCACHE_STATS)
 109 #   define UCACHE_STATS
 110 #  endif /* if !defined(UCACHE_STATS) */
 111 # else
 112 #  undef UCACHE_STATS
 113 # endif /* if !defined(OLDAPP) */
 114 
 115 // Shift/rotate instruction barrel shifter
 116 # define BARREL_SHIFTER 1
 117 
 118 //
 119 // Dependencies
 120 //
 121 
 122 # if defined(PANEL68)
 123 #  define PNL(x) x
 124 # else
 125 #  define PNL(x)
 126 # endif /* if defined(PANEL68) */
 127 
 128 # define L68_(x) if (cpu.tweaks.l68_mode) { x }
 129 # define DPS8M_(x) if (! cpu.tweaks.l68_mode) { x }
 130 
 131 // Debugging tool
 132 # if defined(TESTING)
 133 #  define IF1 if (cpu.tweaks.isolts_mode)
 134 # else
 135 #  define IF1 if (0)
 136 # endif /* if defined(TESTING) */
 137 
 138 // DPS8-M supports Hex Mode Floating Point
 139 # define HEX_MODE
 140 
 141 // Instruction profiler
 142 // #define MATRIX
 143 
 144 // Run TR on work done, not wall clock.
 145 // Define one of these; tied to memory access (MEM)
 146 //  or to instruction execution (EXEC)
 147 //# define TR_WORK_MEM
 148 # define TR_WORK_EXEC
 149 
 150 // Multi-threading may require 'volatile' in some places
 151 # if defined(THREADZ) || defined(LOCKLESS)
 152 #  define vol volatile
 153 # else
 154 #  define vol
 155 # endif /* if defined(THREADZ) || defined(LOCKLESS) */
 156 
 157 # if !defined(NEED_128)
 158 #  if defined(PRIu64)
 159 #   undef PRIu64
 160 #  endif /* if defined(PRIu64) */
 161 #  if !defined(PRIu64)
 162 #   define PRIu64 "llu"
 163 #  endif /* if !defined(PRIu64) */
 164 #  if defined(PRId64)
 165 #   undef PRId64
 166 #  endif /* if defined(PRId64) */
 167 #  if !defined(PRId64)
 168 #   define PRId64 "lld"
 169 #  endif /* if !defined(PRId64) */
 170 #  if defined(PRIo64)
 171 #   undef PRIo64
 172 #  endif /* if defined(PRIo64) */
 173 #  if !defined(PRIo64)
 174 #   if defined(__HAIKU__)
 175 #    define PRIo64 "lo"
 176 #    undef llo
 177 #    define llo "lo"
 178 #   else
 179 #    define PRIo64 "llo"
 180 #   endif /* if defined(__HAIKU__) */
 181 #  endif /* if !defined(PRIo64) */
 182 # endif /* if !defined(NEED_128) */
 183 
 184 # include "../simh/sim_defs.h"           /* simulator defns */
 185 # include "../simh/sim_tape.h"
 186 
 187 # if defined(__MINGW32__)
 188 #  include <stdint.h>
 189 typedef t_uint64    u_int64_t;
 190 # endif /* if defined(__MINGW32__) */
 191 # if defined(__HAIKU__)
 192 #  include <stdint.h>
 193 typedef long int64;
 194 typedef unsigned long uint64;
 195 # endif /* if defined(__HAIKU__) */
 196 # if !defined(__HAIKU__)
 197 typedef t_uint64    uint64;
 198 # endif /* if !defined(__HAIKU__) */
 199 # if !defined(_AIX)
 200 #  if !defined(__HAIKU__)
 201 typedef t_int64     int64;
 202 #  endif /* if !defined(__HAIKU__) */
 203 # else
 204 typedef long        int64;
 205 # endif /* if !defined(_AIX) */
 206 
 207 /* Data types */
 208 
 209 typedef uint8        word1;
 210 typedef uint8        word2;
 211 typedef uint8        word3;
 212 typedef uint8        word4;
 213 typedef uint8        word5;
 214 typedef uint8        word6;
 215 typedef uint8        word7;
 216 typedef uint8        word8;
 217 typedef int8         word8s; // signed 8-bit quantity
 218 typedef uint16       word9;
 219 typedef uint16       word10;
 220 typedef uint16       word11;
 221 typedef uint16       word12;
 222 typedef int16        word12s;
 223 typedef uint16       word13;
 224 typedef uint16       word14;
 225 typedef uint16       word15;
 226 typedef uint16       word16;
 227 typedef uint32       word17;
 228 typedef uint32       word18;
 229 typedef uint32       word19;
 230 typedef int32        word18s;
 231 typedef uint32       word20;
 232 typedef int32        word20s;
 233 typedef uint32       word21;
 234 typedef uint32       word22;
 235 typedef uint32       word23;
 236 typedef uint32       word24;
 237 typedef uint32       word27;
 238 typedef int32        word27s;
 239 typedef uint32       word28;
 240 typedef uint32       word32;
 241 typedef uint64       word34;
 242 typedef uint64       word36;
 243 typedef uint64       word37;
 244 typedef uint64       word38;
 245 typedef int64        word38s;
 246 typedef int64        word36s;
 247 # if !defined(NEED_128)
 248 typedef __uint128_t  word72;
 249 typedef __int128_t   word72s;
 250 typedef __uint128_t  word73;
 251 typedef __uint128_t  word74;
 252 typedef __uint128_t  uint128;
 253 typedef __int128_t   int128;
 254 # else
 255 typedef x__uint128_t word72;
 256 typedef x__int128_t  word72s;
 257 typedef x__uint128_t word73;
 258 typedef x__uint128_t word74;
 259 typedef x__uint128_t uint128;
 260 typedef x__int128_t  int128;
 261 # endif /* if !defined(NEED_128) */
 262 
 263 typedef word36       float36;   // single precision float
 264 typedef word72       float72;   // double precision float
 265 
 266 typedef unsigned int uint;   //-V677   // efficient unsigned int, at least 32 bits
 267 
 268 # include "dps8_simh.h"
 269 # include "dps8_sys.h"
 270 # include "dps8_math128.h"
 271 # include "dps8_hw_consts.h"
 272 # include "dps8_em_consts.h"
 273 
 274 # define SETF(flags, x)       flags = ((flags) |  (x))
 275 # define CLRF(flags, x)       flags = ((flags) & ~(x))
 276 # define TSTF(flags, x)       (((flags) & (x)) ? 1 : 0)
 277 # define SCF(cond, flags, x)  { if (cond) SETF((flags), x); else CLRF((flags), x); }
 278 
 279 # define SETBIT(dst, bitno)   ((dst)  |  (1LLU << (bitno)))
 280 # define CLRBIT(dst, bitno)   ((dst)  & ~(1LLU << (bitno)))
 281 # define TSTBIT(dst, bitno)   (((dst) &  (1LLU << (bitno))) ? 1: 0)
 282 
 283 typedef enum
 284   {
 285     UNKNOWN_CYCLE = 0,
 286     OPERAND_STORE,
 287     OPERAND_READ,
 288     INDIRECT_WORD_FETCH,
 289     RTCD_OPERAND_FETCH,
 290     INSTRUCTION_FETCH,
 291     APU_DATA_READ,
 292     APU_DATA_STORE,
 293     ABSA_CYCLE,
 294 # if defined(LOCKLESS)
 295     OPERAND_RMW,
 296     APU_DATA_RMW,
 297 # endif /* if defined(LOCKLESS) */
 298   } processor_cycle_type;
 299 
 300 # if !defined(LOCKLESS)
 301 #  define OPERAND_RMW   OPERAND_READ
 302 #  define APU_DATA_RMW  APU_DATA_READ
 303 # endif /* if !defined(LOCKLESS) */
 304 
 305 # if !defined(EIS_PTR4)
 306 // some breakpoint stuff ...
 307 typedef enum
 308   {
 309     UnknownMAT       = 0,
 310     OperandRead,
 311     OperandWrite,
 312     viaPR
 313   } MemoryAccessType;
 314 # endif
 315 
 316 // get 6-bit char @ pos
 317 # define GETCHAR(src, pos) (word6)(((word36)src >> (word36)((5 - pos) * 6)) & 077)
 318 // get 9-bit byte @ pos
 319 # define GETBYTE(src, pos) (word9)(((word36)src >> (word36)((3 - pos) * 9)) & 0777)
 320 
 321 # if defined(NEED_128)
 322 #  define YPAIRTO72(ypair) construct_128 ((ypair[0] >> 28) & MASK8,    \
 323                                          ((ypair[0] & MASK28) << 36) | \
 324                                           (ypair[1] & MASK36));
 325 # else
 326 #  define YPAIRTO72(ypair)    (((((word72)(ypair[0] & DMASK)) << 36) | \
 327                                           (ypair[1] & DMASK)) & MASK72)
 328 # endif /* if defined(NEED_128) */
 329 
 330 # define GET_TALLY(src) (((src) >> 6) & MASK12)   // 12-bits
 331 # define GET_DELTA(src)  ((src) & MASK6)          // 6-bits
 332 
 333 # if !defined(max)
 334 #  define max(a,b)   max2((a),(b))
 335 # endif /* if !defined(max) */
 336 # define max2(a,b)   ((a) > (b) ? (a) : (b))
 337 # define max3(a,b,c) max((a), max((b),(c)))
 338 
 339 # if !defined(min)
 340 #  define min(a,b)   min2((a),(b))
 341 # endif /* if !defined(min) */
 342 # define min2(a,b)   ((a) < (b) ? (a) : (b))
 343 # define min3(a,b,c) min((a), min((b),(c)))
 344 
 345 // opcode metadata (flag) ...
 346 typedef enum
 347   {
 348     READ_OPERAND    = (1U <<  0),  // fetches/reads operand (CA) from memory
 349     STORE_OPERAND   = (1U <<  1),  // stores/writes operand to memory (its a STR-OP)
 350 # define RMW             (READ_OPERAND | STORE_OPERAND) // a Read-Modify-Write instruction
 351     READ_YPAIR      = (1U <<  2),  // fetches/reads Y-pair operand (CA) from memory
 352     STORE_YPAIR     = (1U <<  3),  // stores/writes Y-pair operand to memory
 353     READ_YBLOCK8    = (1U <<  4),  // fetches/reads Y-block8 operand (CA) from memory
 354     NO_RPT          = (1U <<  5),  // Repeat instructions not allowed
 355 //#define NO_RPD          (1U << 6)
 356     NO_RPL          = (1U <<  7),
 357 //#define NO_RPX          (NO_RPT | NO_RPD | NO_RPL)
 358     READ_YBLOCK16   = (1U <<  8),  // fetches/reads Y-block16 operands from memory
 359     STORE_YBLOCK16  = (1U <<  9),  // fetches/reads Y-block16 operands from memory
 360     TRANSFER_INS    = (1U << 10),  // a transfer instruction
 361     TSPN_INS        = (1U << 11),  // a TSPn instruction
 362     CALL6_INS       = (1U << 12),  // a call6 instruction
 363     PREPARE_CA      = (1U << 13),  // prepare TPR.CA for instruction
 364     STORE_YBLOCK8   = (1U << 14),  // stores/writes Y-block8 operand to memory
 365     IGN_B29         = (1U << 15),  // Bit-29 has an instruction specific meaning. Ignore.
 366     NO_TAG          = (1U << 16),  // tag is interpreted differently and for addressing purposes is effectively 0
 367     PRIV_INS        = (1U << 17),  // privileged instruction
 368     NO_BAR          = (1U << 18),  // not allowed in BAR mode
 369 //  NO_XEC          = (1U << 19),  // can't be executed via xec/xed
 370     NO_XED          = (1U << 20),  // No execution via XEC/XED instruction
 371 
 372 // EIS operand types
 373 
 374 # define EOP_ALPHA 1U
 375 
 376 // bits 21, 22
 377     EOP1_ALPHA      = (EOP_ALPHA << 21),
 378     EOP1_MASK       = (3U << 21),
 379 # define EOP1_SHIFT 21
 380 
 381 // bits 23, 24
 382     EOP2_ALPHA      = (EOP_ALPHA << 23),
 383     EOP2_MASK       = (3U << 23),
 384 # define EOP2_SHIFT 23
 385 
 386 // bits 25, 26
 387     EOP3_ALPHA      = (EOP_ALPHA << 25),
 388     EOP3_MASK       = (3U << 25),
 389 # define EOP3_SHIFT 25
 390 
 391     READ_YBLOCK32   = (1U << 27),  // fetches/reads Y-block16 operands from memory
 392     STORE_YBLOCK32  = (1U << 28),  // fetches/reads Y-block16 operands from memory
 393   } opc_flag;
 394 
 395 // opcode metadata (disallowed) modifications
 396 enum opc_mod
 397   {
 398     NO_DU           = (1U << 0),   // No DU modification allowed (Can these 2 be combined into 1?)
 399     NO_DL           = (1U << 1),   // No DL modification allowed
 400 # define NO_DUDL    (NO_DU | NO_DL)
 401 
 402     NO_CI           = (1U << 2),   // No character indirect modification (can these next 3 be combined?
 403     NO_SC           = (1U << 3),   // No sequence character modification
 404     NO_SCR          = (1U << 4),   // No sequence character reverse modification
 405 # define NO_CSS     (NO_CI | NO_SC | NO_SCR)
 406 
 407 # define NO_DLCSS   (NO_DU   | NO_CSS)
 408 # define NO_DDCSS   (NO_DUDL | NO_CSS)
 409 
 410     ONLY_AU_QU_AL_QL_XN = (1U << 5)    // None except au, qu, al, ql, xn
 411   };
 412 
 413 // None except au, qu, al, ql, xn for MF1 and REG
 414 // None except du, au, qu, al, ql, xn for MF2
 415 // None except au, qu, al, ql, xn for MF1, MF2, and MF3
 416 
 417 # define IS_NONE(tag) (!(tag))
 418 /*! non-tally: du or dl */
 419 # define IS_DD(tag) ((_TM(tag) != 040U) && \
 420     ((_TD(tag) == 003U) || (_TD(tag) == 007U)))
 421 /*! tally: ci, sc, or scr */
 422 # define IS_CSS(tag) ((_TM(tag) == 040U) && \
 423     ((_TD(tag) == 050U) || (_TD(tag) == 052U) || \
 424     (_TD(tag) == 045U)))
 425 # define IS_DDCSS(tag) (IS_DD(tag) || IS_CSS(tag))
 426 /*! just dl or css */
 427 # define IS_DCSS(tag) (((_TM(tag) != 040U) && (_TD(tag) == 007U)) || IS_CSS(tag))
 428 
 429 // !%WRD  ~0200000  017
 430 // !%9    ~0100000  027
 431 // !%6    ~0040000  033
 432 // !%4    ~0020000  035
 433 // !%1    ~0010000  036
 434 enum reg_use { is_WRD =  0174000,
 435                is_9  =   0274000,
 436                is_6  =   0334000,
 437                is_4  =   0354000,
 438                is_1  =   0364000,
 439                is_DU =   04000,
 440                is_OU =   02000,
 441                ru_A  =   02000 | 01000,
 442                ru_Q  =   02000 |  0400,
 443                ru_X0 =   02000 |  0200,
 444                ru_X1 =   02000 |  0100,
 445                ru_X2 =   02000 |   040,
 446                ru_X3 =   02000 |   020,
 447                ru_X4 =   02000 |   010,
 448                ru_X5 =   02000 |    04,
 449                ru_X6 =   02000 |    02,
 450                ru_X7 =   02000 |    01,
 451                ru_none = 02000 |     0 };
 452 //, ru_notou = 1024 };
 453 
 454 # define ru_AQ (ru_A | ru_Q)
 455 # define ru_Xn(n) (1 << (7 - (n)))
 456 
 457 // Basic + EIS opcodes .....
 458 struct opcode_s {
 459     const char *mne;       // mnemonic
 460     opc_flag flags;        // various and sundry flags
 461     enum opc_mod mods;          // disallowed addr mods
 462     uint ndes;             // number of operand descriptor words for instruction (mw EIS)
 463     enum reg_use reg_use;  // register usage
 464 };
 465 
 466 // operations stuff
 467 
 468 /*! Y of instruc word */
 469 # define Y(i) (i & MASKHI18)
 470 /*! X from opcodes in instruc word */
 471 # define OPSX(i) ((i & 0007000LLU) >> 9)
 472 /*! X from OP_* enum, and X from  */
 473 # define X(i) (i & 07U)
 474 
 475 enum { OP_1     = 00001U,
 476     OP_E        = 00002U,
 477     OP_BAR      = 00003U,
 478     OP_IC       = 00004U,
 479     OP_A        = 00005U,
 480     OP_Q        = 00006U,
 481     OP_AQ       = 00007U,
 482     OP_IR       = 00010U,
 483     OP_TR       = 00011U,
 484     OP_REGS     = 00012U,
 485 
 486     /* 645/6180 */
 487     OP_CPR      = 00021U,
 488     OP_DBR      = 00022U,
 489     OP_PTP      = 00023U,
 490     OP_PTR      = 00024U,
 491     OP_RA       = 00025U,
 492     OP_SDP      = 00026U,
 493     OP_SDR      = 00027U,
 494 
 495     OP_X        = 01000U
 496 };
 497 
 498 enum eCAFoper {
 499     unknown = 0,
 500     readCY,
 501     writeCY,
 502     rmwCY,      // Read-Modify-Write
 503 //    readCYpair,
 504 //    writeCYpair,
 505 //    readCYblock8,
 506 //    writeCYblock8,
 507 //    readCYblock16,
 508 //    writeCYblock16,
 509 
 510     prepareCA,
 511 };
 512 typedef enum eCAFoper eCAFoper;
 513 
 514 # define READOP(i) ((bool) (i->info->flags    &  \
 515                            (READ_OPERAND      |  \
 516                             READ_YPAIR        |  \
 517                             READ_YBLOCK8      |  \
 518                             READ_YBLOCK16     |  \
 519                             READ_YBLOCK32)))
 520 
 521 # define WRITEOP(i) ((bool) (i->info->flags   &  \
 522                             (STORE_OPERAND    |  \
 523                              STORE_YPAIR      |  \
 524                              STORE_YBLOCK8    |  \
 525                              STORE_YBLOCK16   |  \
 526                              STORE_YBLOCK32)))
 527 
 528 // if it's both read and write it's a RMW
 529 # define RMWOP(i) ((bool) READOP(i) && WRITEOP(i))
 530 
 531 # define TRANSOP(i) ((bool) (i->info->flags & (TRANSFER_INS) ))
 532 
 533 //
 534 // EIS stuff ...
 535 //
 536 
 537 // Numeric operand descriptors
 538 
 539 // AL39 Table 4-3. Alphanumeric Data Type (TA) Codes
 540 enum
 541   {
 542     CTA9   = 0U, // 9-bit bytes
 543     CTA6   = 1U, // 6-bit characters
 544     CTA4   = 2U, // 4-bit decimal
 545     CTAILL = 3U  // Illegal
 546   };
 547 
 548 // TN - Type Numeric AL39 Table 4-3. Alphanumeric Data Type (TN) Codes
 549 enum
 550   {
 551     CTN9 = 0U,   // 9-bit
 552     CTN4 = 1U    // 4-bit
 553   };
 554 
 555 // S - Sign and Decimal Type (AL39 Table 4-4. Sign and Decimal Type (S) Codes)
 556 
 557 enum
 558   {
 559     CSFL = 0U,   // Floating-point, leading sign
 560     CSLS = 1U,   // Scaled fixed-point, leading sign
 561     CSTS = 2U,   // Scaled fixed-point, trailing sign
 562     CSNS = 3U    // Scaled fixed-point, unsigned
 563   };
 564 
 565 enum
 566   {
 567     // Address register flag. This flag controls interpretation of the ADDRESS
 568     // field of the operand descriptor just as the "A" flag controls
 569     // interpretation of the ADDRESS field of the basic and EIS single-word
 570     // instructions.
 571     MFkAR = 0x40U,
 572     // Register length control. If RL = 0, then the length (N) field of the
 573     // operand descriptor contains the length of the operand. If RL = 1, then
 574     // the length (N) field of the operand descriptor contains a selector value
 575     // specifying a register holding the operand length. Operand length is
 576     // interpreted as units of the data size (1-, 4-, 6-, or 9-bit) given in
 577     // the associated operand descriptor.
 578     MFkRL = 0x20U,
 579     // Indirect descriptor control. If ID = 1 for Mfk, then the kth word
 580     // following the instruction word is an indirect pointer to the operand
 581     // descriptor for the kth operand; otherwise, that word is the operand
 582     // descriptor.
 583     MFkID = 0x10U,
 584 
 585     MFkREGMASK = 0xfU
 586   };
 587 
 588 // EIS instruction take on a life of their own. Need to take into account
 589 // RNR/SNR/BAR etc.
 590 typedef enum
 591   {
 592     eisUnknown = 0,  // uninitialized
 593     eisTA      = 1,  // type alphanumeric
 594     eisTN      = 2,  // type numeric
 595     eisBIT     = 3   // bit string
 596   } eisDataType;
 597 
 598 typedef enum
 599   {
 600     eRWreadBit = 0,
 601     eRWwriteBit
 602   } eRW;
 603 
 604 // Misc constants and macros
 605 
 606 # define ARRAY_SIZE(a) ( sizeof(a) / sizeof((a)[0]) )
 607 
 608 # if defined(FREE)
 609 #  undef FREE
 610 # endif /* if defined(FREE) */
 611 # define FREE(p) do  \
 612   {                  \
 613     free((p));       \
 614     (p) = NULL;      \
 615   } while(0)
 616 
 617 # if defined(__GNUC__) || defined(__clang_version__)
 618 #  if !defined(LIKELY)
 619 #   define LIKELY(x) __builtin_expect(!!(x), 1)
 620 #  endif
 621 #  if !defined(UNLIKELY)
 622 #   define UNLIKELY(x) __builtin_expect(!!(x), 0)
 623 #  endif
 624 # else
 625 #  if !defined(LIKELY)
 626 #   define LIKELY(x) (x)
 627 #  endif
 628 #  if !defined(UNLIKELY)
 629 #   define UNLIKELY(x) (x)
 630 #  endif
 631 # endif
 632 
 633 # if defined (__MINGW64__) || \
 634     defined (__MINGW32__)  || \
 635     defined (__GNUC__)     || \
 636     defined (__clang_version__)
 637 #  define UNUSED    __attribute__ ((unused))
 638 # else
 639 #  define UNUSED
 640 # endif
 641 
 642 /* Detect proper "does not return" annotation */
 643 # if !defined(NO_RETURN)
 644 #  if defined(__STDC_VERSION__)
 645 #   if __STDC_VERSION__ >= 202311L
 646 #    define NO_RETURN [[noreturn]] /* C23-style */
 647 #   elif __STDC_VERSION__ >= 201112L
 648 #    define NO_RETURN _Noreturn /* C11-style */
 649 #   endif
 650 #  endif
 651 # endif
 652 # if !defined(NO_RETURN)
 653 #  if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) || \
 654       defined(__xlc__) || defined(__ibmxl__)
 655 #   define NO_RETURN __attribute__((noreturn)) /* IBM/Sun/GNU-style */
 656 #  endif
 657 # endif
 658 # if !defined(NO_RETURN)
 659 #  define NO_RETURN /* Fallback */
 660 # endif
 661 
 662 # define MAX_DEV_NAME_LEN 64
 663 
 664 // Basic STDIO for MinGW
 665 # if !defined(__CYGWIN__)
 666 #  if defined(__MINGW32__) || defined(__MINGW64__) || defined(CROSS_MINGW32) || defined(CROSS_MINGW64)
 667 #   define WIN_STDIO    1
 668 #  endif /* if defined(__MINGW32__) || defined(__MINGW64__) || defined(CROSS_MINGW32) || defined(CROSS_MINGW64) */
 669 # endif /* if !defined(__CYGWIN__) */
 670 
 671 //#define SYNCTEST
 672 
 673 #endif // if defined(DPS8_H)

/* [previous][next][first][last][top][bottom][index][help] */