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

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