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

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