root/lj_arch.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2 ** Target architecture selection.
   3 ** Copyright (C) 2005-2017 Mike Pall. See Copyright Notice in luajit.h
   4 */
   5 
   6 #ifndef _LJ_ARCH_H
   7 #define _LJ_ARCH_H
   8 
   9 #include "lua.h"
  10 
  11 /* Target endianess. */
  12 #define LUAJIT_LE       0
  13 #define LUAJIT_BE       1
  14 
  15 /* Target architectures. */
  16 #define LUAJIT_ARCH_X86         1
  17 #define LUAJIT_ARCH_x86         1
  18 #define LUAJIT_ARCH_X64         2
  19 #define LUAJIT_ARCH_x64         2
  20 #define LUAJIT_ARCH_ARM         3
  21 #define LUAJIT_ARCH_arm         3
  22 #define LUAJIT_ARCH_ARM64       4
  23 #define LUAJIT_ARCH_arm64       4
  24 #define LUAJIT_ARCH_PPC         5
  25 #define LUAJIT_ARCH_ppc         5
  26 #define LUAJIT_ARCH_MIPS        6
  27 #define LUAJIT_ARCH_mips        6
  28 #define LUAJIT_ARCH_MIPS32      6
  29 #define LUAJIT_ARCH_mips32      6
  30 #define LUAJIT_ARCH_MIPS64      7
  31 #define LUAJIT_ARCH_mips64      7
  32 
  33 /* Target OS. */
  34 #define LUAJIT_OS_OTHER         0
  35 #define LUAJIT_OS_WINDOWS       1
  36 #define LUAJIT_OS_LINUX         2
  37 #define LUAJIT_OS_OSX           3
  38 #define LUAJIT_OS_BSD           4
  39 #define LUAJIT_OS_POSIX         5
  40 
  41 /* Select native target if no target defined. */
  42 #ifndef LUAJIT_TARGET
  43 
  44 #if defined(__i386) || defined(__i386__) || defined(_M_IX86)
  45 #define LUAJIT_TARGET   LUAJIT_ARCH_X86
  46 #elif defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)
  47 #define LUAJIT_TARGET   LUAJIT_ARCH_X64
  48 #elif defined(__arm__) || defined(__arm) || defined(__ARM__) || defined(__ARM)
  49 #define LUAJIT_TARGET   LUAJIT_ARCH_ARM
  50 #elif defined(__aarch64__)
  51 #define LUAJIT_TARGET   LUAJIT_ARCH_ARM64
  52 #elif defined(__ppc__) || defined(__ppc) || defined(__PPC__) || defined(__PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__POWERPC) || defined(_M_PPC)
  53 #define LUAJIT_TARGET   LUAJIT_ARCH_PPC
  54 #elif defined(__mips64__) || defined(__mips64) || defined(__MIPS64__) || defined(__MIPS64)
  55 #define LUAJIT_TARGET   LUAJIT_ARCH_MIPS64
  56 #elif defined(__mips__) || defined(__mips) || defined(__MIPS__) || defined(__MIPS)
  57 #define LUAJIT_TARGET   LUAJIT_ARCH_MIPS32
  58 #else
  59 #error "No support for this architecture (yet)"
  60 #endif
  61 
  62 #endif
  63 
  64 /* Select native OS if no target OS defined. */
  65 #ifndef LUAJIT_OS
  66 
  67 #if defined(_WIN32) && !defined(_XBOX_VER)
  68 #define LUAJIT_OS       LUAJIT_OS_WINDOWS
  69 #elif defined(__linux__)
  70 #define LUAJIT_OS       LUAJIT_OS_LINUX
  71 #elif defined(__MACH__) && defined(__APPLE__)
  72 #define LUAJIT_OS       LUAJIT_OS_OSX
  73 #elif (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
  74        defined(__NetBSD__) || defined(__OpenBSD__) || \
  75        defined(__DragonFly__)) && !defined(__ORBIS__)
  76 #define LUAJIT_OS       LUAJIT_OS_BSD
  77 #elif (defined(__sun__) && defined(__svr4__)) || defined(__HAIKU__)
  78 #define LUAJIT_OS       LUAJIT_OS_POSIX
  79 #elif defined(__CYGWIN__)
  80 #define LJ_TARGET_CYGWIN        1
  81 #define LUAJIT_OS       LUAJIT_OS_POSIX
  82 #else
  83 #define LUAJIT_OS       LUAJIT_OS_OTHER
  84 #endif
  85 
  86 #endif
  87 
  88 /* Set target OS properties. */
  89 #if LUAJIT_OS == LUAJIT_OS_WINDOWS
  90 #define LJ_OS_NAME      "Windows"
  91 #elif LUAJIT_OS == LUAJIT_OS_LINUX
  92 #define LJ_OS_NAME      "Linux"
  93 #elif LUAJIT_OS == LUAJIT_OS_OSX
  94 #define LJ_OS_NAME      "OSX"
  95 #elif LUAJIT_OS == LUAJIT_OS_BSD
  96 #define LJ_OS_NAME      "BSD"
  97 #elif LUAJIT_OS == LUAJIT_OS_POSIX
  98 #define LJ_OS_NAME      "POSIX"
  99 #else
 100 #define LJ_OS_NAME      "Other"
 101 #endif
 102 
 103 #define LJ_TARGET_WINDOWS       (LUAJIT_OS == LUAJIT_OS_WINDOWS)
 104 #define LJ_TARGET_LINUX         (LUAJIT_OS == LUAJIT_OS_LINUX)
 105 #define LJ_TARGET_OSX           (LUAJIT_OS == LUAJIT_OS_OSX)
 106 #define LJ_TARGET_IOS           (LJ_TARGET_OSX && (LUAJIT_TARGET == LUAJIT_ARCH_ARM || LUAJIT_TARGET == LUAJIT_ARCH_ARM64))
 107 #define LJ_TARGET_POSIX         (LUAJIT_OS > LUAJIT_OS_WINDOWS)
 108 #define LJ_TARGET_DLOPEN        LJ_TARGET_POSIX
 109 
 110 #ifdef __CELLOS_LV2__
 111 #define LJ_TARGET_PS3           1
 112 #define LJ_TARGET_CONSOLE       1
 113 #endif
 114 
 115 #ifdef __ORBIS__
 116 #define LJ_TARGET_PS4           1
 117 #define LJ_TARGET_CONSOLE       1
 118 #undef NULL
 119 #define NULL ((void*)0)
 120 #endif
 121 
 122 #ifdef __psp2__
 123 #define LJ_TARGET_PSVITA        1
 124 #define LJ_TARGET_CONSOLE       1
 125 #endif
 126 
 127 #if _XBOX_VER >= 200
 128 #define LJ_TARGET_XBOX360       1
 129 #define LJ_TARGET_CONSOLE       1
 130 #endif
 131 
 132 #ifdef _DURANGO
 133 #define LJ_TARGET_XBOXONE       1
 134 #define LJ_TARGET_CONSOLE       1
 135 #define LJ_TARGET_GC64          1
 136 #endif
 137 
 138 #ifdef _UWP
 139 #define LJ_TARGET_UWP           1
 140 #if LUAJIT_TARGET == LUAJIT_ARCH_X64
 141 #define LJ_TARGET_GC64          1
 142 #endif
 143 #endif
 144 
 145 #define LJ_NUMMODE_SINGLE       0       /* Single-number mode only. */
 146 #define LJ_NUMMODE_SINGLE_DUAL  1       /* Default to single-number mode. */
 147 #define LJ_NUMMODE_DUAL         2       /* Dual-number mode only. */
 148 #define LJ_NUMMODE_DUAL_SINGLE  3       /* Default to dual-number mode. */
 149 
 150 /* Set target architecture properties. */
 151 #if LUAJIT_TARGET == LUAJIT_ARCH_X86
 152 
 153 #define LJ_ARCH_NAME            "x86"
 154 #define LJ_ARCH_BITS            32
 155 #define LJ_ARCH_ENDIAN          LUAJIT_LE
 156 #if LJ_TARGET_WINDOWS || LJ_TARGET_CYGWIN
 157 #define LJ_ABI_WIN              1
 158 #else
 159 #define LJ_ABI_WIN              0
 160 #endif
 161 #define LJ_TARGET_X86           1
 162 #define LJ_TARGET_X86ORX64      1
 163 #define LJ_TARGET_EHRETREG      0
 164 #define LJ_TARGET_MASKSHIFT     1
 165 #define LJ_TARGET_MASKROT       1
 166 #define LJ_TARGET_UNALIGNED     1
 167 #define LJ_ARCH_NUMMODE         LJ_NUMMODE_SINGLE_DUAL
 168 
 169 #elif LUAJIT_TARGET == LUAJIT_ARCH_X64
 170 
 171 #define LJ_ARCH_NAME            "x64"
 172 #define LJ_ARCH_BITS            64
 173 #define LJ_ARCH_ENDIAN          LUAJIT_LE
 174 #if LJ_TARGET_WINDOWS || LJ_TARGET_CYGWIN
 175 #define LJ_ABI_WIN              1
 176 #else
 177 #define LJ_ABI_WIN              0
 178 #endif
 179 #define LJ_TARGET_X64           1
 180 #define LJ_TARGET_X86ORX64      1
 181 #define LJ_TARGET_EHRETREG      0
 182 #define LJ_TARGET_JUMPRANGE     31      /* +-2^31 = +-2GB */
 183 #define LJ_TARGET_MASKSHIFT     1
 184 #define LJ_TARGET_MASKROT       1
 185 #define LJ_TARGET_UNALIGNED     1
 186 #define LJ_ARCH_NUMMODE         LJ_NUMMODE_SINGLE_DUAL
 187 #ifdef LUAJIT_ENABLE_GC64
 188 #define LJ_TARGET_GC64          1
 189 #endif
 190 
 191 #elif LUAJIT_TARGET == LUAJIT_ARCH_ARM
 192 
 193 #define LJ_ARCH_NAME            "arm"
 194 #define LJ_ARCH_BITS            32
 195 #define LJ_ARCH_ENDIAN          LUAJIT_LE
 196 #if !defined(LJ_ARCH_HASFPU) && __SOFTFP__
 197 #define LJ_ARCH_HASFPU          0
 198 #endif
 199 #if !defined(LJ_ABI_SOFTFP) && !__ARM_PCS_VFP
 200 #define LJ_ABI_SOFTFP           1
 201 #endif
 202 #define LJ_ABI_EABI             1
 203 #define LJ_TARGET_ARM           1
 204 #define LJ_TARGET_EHRETREG      0
 205 #define LJ_TARGET_JUMPRANGE     25      /* +-2^25 = +-32MB */
 206 #define LJ_TARGET_MASKSHIFT     0
 207 #define LJ_TARGET_MASKROT       1
 208 #define LJ_TARGET_UNIFYROT      2       /* Want only IR_BROR. */
 209 #define LJ_ARCH_NUMMODE         LJ_NUMMODE_DUAL
 210 
 211 #if __ARM_ARCH_8__ || __ARM_ARCH_8A__
 212 #define LJ_ARCH_VERSION         80
 213 #elif __ARM_ARCH_7__ || __ARM_ARCH_7A__ || __ARM_ARCH_7R__ || __ARM_ARCH_7S__ || __ARM_ARCH_7VE__
 214 #define LJ_ARCH_VERSION         70
 215 #elif __ARM_ARCH_6T2__
 216 #define LJ_ARCH_VERSION         61
 217 #elif __ARM_ARCH_6__ || __ARM_ARCH_6J__ || __ARM_ARCH_6K__ || __ARM_ARCH_6Z__ || __ARM_ARCH_6ZK__
 218 #define LJ_ARCH_VERSION         60
 219 #else
 220 #define LJ_ARCH_VERSION         50
 221 #endif
 222 
 223 #elif LUAJIT_TARGET == LUAJIT_ARCH_ARM64
 224 
 225 #define LJ_ARCH_BITS            64
 226 #if defined(__AARCH64EB__)
 227 #define LJ_ARCH_NAME            "arm64be"
 228 #define LJ_ARCH_ENDIAN          LUAJIT_BE
 229 #else
 230 #define LJ_ARCH_NAME            "arm64"
 231 #define LJ_ARCH_ENDIAN          LUAJIT_LE
 232 #endif
 233 #define LJ_TARGET_ARM64         1
 234 #define LJ_TARGET_EHRETREG      0
 235 #define LJ_TARGET_JUMPRANGE     27      /* +-2^27 = +-128MB */
 236 #define LJ_TARGET_MASKSHIFT     1
 237 #define LJ_TARGET_MASKROT       1
 238 #define LJ_TARGET_UNIFYROT      2       /* Want only IR_BROR. */
 239 #define LJ_TARGET_GC64          1
 240 #define LJ_ARCH_NUMMODE         LJ_NUMMODE_DUAL
 241 
 242 #define LJ_ARCH_VERSION         80
 243 
 244 #elif LUAJIT_TARGET == LUAJIT_ARCH_PPC
 245 
 246 #ifndef LJ_ARCH_ENDIAN
 247 #if __BYTE_ORDER__ != __ORDER_BIG_ENDIAN__
 248 #define LJ_ARCH_ENDIAN          LUAJIT_LE
 249 #else
 250 #define LJ_ARCH_ENDIAN          LUAJIT_BE
 251 #endif
 252 #endif
 253 
 254 #if _LP64
 255 #define LJ_ARCH_BITS            64
 256 #if LJ_ARCH_ENDIAN == LUAJIT_LE
 257 #define LJ_ARCH_NAME            "ppc64le"
 258 #else
 259 #define LJ_ARCH_NAME            "ppc64"
 260 #endif
 261 #else
 262 #define LJ_ARCH_BITS            32
 263 #define LJ_ARCH_NAME            "ppc"
 264 
 265 #if !defined(LJ_ARCH_HASFPU)
 266 #if defined(_SOFT_FLOAT) || defined(_SOFT_DOUBLE)
 267 #define LJ_ARCH_HASFPU          0
 268 #else
 269 #define LJ_ARCH_HASFPU          1
 270 #endif
 271 #endif
 272 
 273 #if !defined(LJ_ABI_SOFTFP)
 274 #if defined(_SOFT_FLOAT) || defined(_SOFT_DOUBLE)
 275 #define LJ_ABI_SOFTFP           1
 276 #else
 277 #define LJ_ABI_SOFTFP           0
 278 #endif
 279 #endif
 280 #endif
 281 
 282 #if LJ_ABI_SOFTFP
 283 #define LJ_ARCH_NUMMODE         LJ_NUMMODE_DUAL
 284 #else
 285 #define LJ_ARCH_NUMMODE         LJ_NUMMODE_DUAL_SINGLE
 286 #endif
 287 
 288 #define LJ_TARGET_PPC           1
 289 #define LJ_TARGET_EHRETREG      3
 290 #define LJ_TARGET_JUMPRANGE     25      /* +-2^25 = +-32MB */
 291 #define LJ_TARGET_MASKSHIFT     0
 292 #define LJ_TARGET_MASKROT       1
 293 #define LJ_TARGET_UNIFYROT      1       /* Want only IR_BROL. */
 294 
 295 #if LJ_TARGET_CONSOLE
 296 #define LJ_ARCH_PPC32ON64       1
 297 #define LJ_ARCH_NOFFI           1
 298 #elif LJ_ARCH_BITS == 64
 299 #define LJ_ARCH_PPC64           1
 300 #define LJ_TARGET_GC64          1
 301 #define LJ_ARCH_NOJIT           1       /* NYI */
 302 #endif
 303 
 304 #if _ARCH_PWR7
 305 #define LJ_ARCH_VERSION         70
 306 #elif _ARCH_PWR6
 307 #define LJ_ARCH_VERSION         60
 308 #elif _ARCH_PWR5X
 309 #define LJ_ARCH_VERSION         51
 310 #elif _ARCH_PWR5
 311 #define LJ_ARCH_VERSION         50
 312 #elif _ARCH_PWR4
 313 #define LJ_ARCH_VERSION         40
 314 #else
 315 #define LJ_ARCH_VERSION         0
 316 #endif
 317 #if _ARCH_PPCSQ
 318 #define LJ_ARCH_SQRT            1
 319 #endif
 320 #if _ARCH_PWR5X
 321 #define LJ_ARCH_ROUND           1
 322 #endif
 323 #if __PPU__
 324 #define LJ_ARCH_CELL            1
 325 #endif
 326 #if LJ_TARGET_XBOX360
 327 #define LJ_ARCH_XENON           1
 328 #endif
 329 
 330 #elif LUAJIT_TARGET == LUAJIT_ARCH_MIPS32 || LUAJIT_TARGET == LUAJIT_ARCH_MIPS64
 331 
 332 #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL)
 333 #if LUAJIT_TARGET == LUAJIT_ARCH_MIPS32
 334 #define LJ_ARCH_NAME            "mipsel"
 335 #else
 336 #define LJ_ARCH_NAME            "mips64el"
 337 #endif
 338 #define LJ_ARCH_ENDIAN          LUAJIT_LE
 339 #else
 340 #if LUAJIT_TARGET == LUAJIT_ARCH_MIPS32
 341 #define LJ_ARCH_NAME            "mips"
 342 #else
 343 #define LJ_ARCH_NAME            "mips64"
 344 #endif
 345 #define LJ_ARCH_ENDIAN          LUAJIT_BE
 346 #endif
 347 
 348 #if !defined(LJ_ARCH_HASFPU)
 349 #ifdef __mips_soft_float
 350 #define LJ_ARCH_HASFPU          0
 351 #else
 352 #define LJ_ARCH_HASFPU          1
 353 #endif
 354 #endif
 355 
 356 #if !defined(LJ_ABI_SOFTFP)
 357 #ifdef __mips_soft_float
 358 #define LJ_ABI_SOFTFP           1
 359 #else
 360 #define LJ_ABI_SOFTFP           0
 361 #endif
 362 #endif
 363 
 364 #if LUAJIT_TARGET == LUAJIT_ARCH_MIPS32
 365 #define LJ_ARCH_BITS            32
 366 #define LJ_TARGET_MIPS32        1
 367 #else
 368 #define LJ_ARCH_BITS            64
 369 #define LJ_TARGET_MIPS64        1
 370 #define LJ_TARGET_GC64          1
 371 #endif
 372 #define LJ_TARGET_MIPS          1
 373 #define LJ_TARGET_EHRETREG      4
 374 #define LJ_TARGET_JUMPRANGE     27      /* 2*2^27 = 256MB-aligned region */
 375 #define LJ_TARGET_MASKSHIFT     1
 376 #define LJ_TARGET_MASKROT       1
 377 #define LJ_TARGET_UNIFYROT      2       /* Want only IR_BROR. */
 378 #define LJ_ARCH_NUMMODE         LJ_NUMMODE_DUAL
 379 
 380 #if _MIPS_ARCH_MIPS32R2 || _MIPS_ARCH_MIPS64R2
 381 #define LJ_ARCH_VERSION         20
 382 #else
 383 #define LJ_ARCH_VERSION         10
 384 #endif
 385 
 386 #else
 387 #error "No target architecture defined"
 388 #endif
 389 
 390 #ifndef LJ_PAGESIZE
 391 #define LJ_PAGESIZE             4096
 392 #endif
 393 
 394 /* Check for minimum required compiler versions. */
 395 #if defined(__GNUC__)
 396 #if LJ_TARGET_X86
 397 #if (__GNUC__ < 3) || ((__GNUC__ == 3) && __GNUC_MINOR__ < 4)
 398 #error "Need at least GCC 3.4 or newer"
 399 #endif
 400 #elif LJ_TARGET_X64
 401 #if __GNUC__ < 4
 402 #error "Need at least GCC 4.0 or newer"
 403 #endif
 404 #elif LJ_TARGET_ARM
 405 #if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 2)
 406 #error "Need at least GCC 4.2 or newer"
 407 #endif
 408 #elif LJ_TARGET_ARM64
 409 #if __clang__
 410 #if ((__clang_major__ < 3) || ((__clang_major__ == 3) && __clang_minor__ < 5)) && !defined(__NX_TOOLCHAIN_MAJOR__)
 411 #error "Need at least Clang 3.5 or newer"
 412 #endif
 413 #else
 414 #if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 8)
 415 #error "Need at least GCC 4.8 or newer"
 416 #endif
 417 #endif
 418 #elif !LJ_TARGET_PS3
 419 #if (__GNUC__ < 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ < 3)
 420 #error "Need at least GCC 4.3 or newer"
 421 #endif
 422 #endif
 423 #endif
 424 
 425 /* Check target-specific constraints. */
 426 #ifndef _BUILDVM_H
 427 #if LJ_TARGET_X64
 428 #if __USING_SJLJ_EXCEPTIONS__
 429 #error "Need a C compiler with native exception handling on x64"
 430 #endif
 431 #elif LJ_TARGET_ARM
 432 #if defined(__ARMEB__)
 433 #error "No support for big-endian ARM"
 434 #endif
 435 #if __ARM_ARCH_6M__ || __ARM_ARCH_7M__ || __ARM_ARCH_7EM__
 436 #error "No support for Cortex-M CPUs"
 437 #endif
 438 #if !(__ARM_EABI__ || LJ_TARGET_IOS)
 439 #error "Only ARM EABI or iOS 3.0+ ABI is supported"
 440 #endif
 441 #elif LJ_TARGET_ARM64
 442 #if defined(_ILP32)
 443 #error "No support for ILP32 model on ARM64"
 444 #endif
 445 #elif LJ_TARGET_PPC
 446 #if !LJ_ARCH_PPC64 && (defined(_LITTLE_ENDIAN) && (!defined(_BYTE_ORDER) || (_BYTE_ORDER == _LITTLE_ENDIAN)))
 447 #error "No support for little-endian PPC32"
 448 #endif
 449 #if defined(__NO_FPRS__) && !defined(_SOFT_FLOAT)
 450 #error "No support for PPC/e500 anymore (use LuaJIT 2.0)"
 451 #endif
 452 #elif LJ_TARGET_MIPS32
 453 #if !((defined(_MIPS_SIM_ABI32) && _MIPS_SIM == _MIPS_SIM_ABI32) || (defined(_ABIO32) && _MIPS_SIM == _ABIO32))
 454 #error "Only o32 ABI supported for MIPS32"
 455 #endif
 456 #elif LJ_TARGET_MIPS64
 457 #if !((defined(_MIPS_SIM_ABI64) && _MIPS_SIM == _MIPS_SIM_ABI64) || (defined(_ABI64) && _MIPS_SIM == _ABI64))
 458 #error "Only n64 ABI supported for MIPS64"
 459 #endif
 460 #endif
 461 #endif
 462 
 463 /* Enable or disable the dual-number mode for the VM. */
 464 #if (LJ_ARCH_NUMMODE == LJ_NUMMODE_SINGLE && LUAJIT_NUMMODE == 2) || \
 465     (LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL && LUAJIT_NUMMODE == 1)
 466 #error "No support for this number mode on this architecture"
 467 #endif
 468 #if LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL || \
 469     (LJ_ARCH_NUMMODE == LJ_NUMMODE_DUAL_SINGLE && LUAJIT_NUMMODE != 1) || \
 470     (LJ_ARCH_NUMMODE == LJ_NUMMODE_SINGLE_DUAL && LUAJIT_NUMMODE == 2)
 471 #define LJ_DUALNUM              1
 472 #else
 473 #define LJ_DUALNUM              0
 474 #endif
 475 
 476 #if LJ_TARGET_IOS || LJ_TARGET_CONSOLE
 477 /* Runtime code generation is restricted on iOS. Complain to Apple, not me. */
 478 /* Ditto for the consoles. Complain to Sony or MS, not me. */
 479 #ifndef LUAJIT_ENABLE_JIT
 480 #define LJ_OS_NOJIT             1
 481 #endif
 482 #endif
 483 
 484 /* 64 bit GC references. */
 485 #if LJ_TARGET_GC64
 486 #define LJ_GC64                 1
 487 #else
 488 #define LJ_GC64                 0
 489 #endif
 490 
 491 /* 2-slot frame info. */
 492 #if LJ_GC64
 493 #define LJ_FR2                  1
 494 #else
 495 #define LJ_FR2                  0
 496 #endif
 497 
 498 /* Disable or enable the JIT compiler. */
 499 #if defined(LUAJIT_DISABLE_JIT) || defined(LJ_ARCH_NOJIT) || defined(LJ_OS_NOJIT)
 500 #define LJ_HASJIT               0
 501 #else
 502 #define LJ_HASJIT               1
 503 #endif
 504 
 505 /* Disable or enable the FFI extension. */
 506 #if defined(LUAJIT_DISABLE_FFI) || defined(LJ_ARCH_NOFFI)
 507 #define LJ_HASFFI               0
 508 #else
 509 #define LJ_HASFFI               1
 510 #endif
 511 
 512 #if defined(LUAJIT_DISABLE_PROFILE)
 513 #define LJ_HASPROFILE           0
 514 #elif LJ_TARGET_POSIX
 515 #define LJ_HASPROFILE           1
 516 #define LJ_PROFILE_SIGPROF      1
 517 #elif LJ_TARGET_PS3
 518 #define LJ_HASPROFILE           1
 519 #define LJ_PROFILE_PTHREAD      1
 520 #elif LJ_TARGET_WINDOWS || LJ_TARGET_XBOX360
 521 #define LJ_HASPROFILE           1
 522 #define LJ_PROFILE_WTHREAD      1
 523 #else
 524 #define LJ_HASPROFILE           0
 525 #endif
 526 
 527 #ifndef LJ_ARCH_HASFPU
 528 #define LJ_ARCH_HASFPU          1
 529 #endif
 530 #ifndef LJ_ABI_SOFTFP
 531 #define LJ_ABI_SOFTFP           0
 532 #endif
 533 #define LJ_SOFTFP               (!LJ_ARCH_HASFPU)
 534 #define LJ_SOFTFP32             (LJ_SOFTFP && LJ_32)
 535 
 536 #if LJ_ARCH_ENDIAN == LUAJIT_BE
 537 #define LJ_LE                   0
 538 #define LJ_BE                   1
 539 #define LJ_ENDIAN_SELECT(le, be)        be
 540 #define LJ_ENDIAN_LOHI(lo, hi)          hi lo
 541 #else
 542 #define LJ_LE                   1
 543 #define LJ_BE                   0
 544 #define LJ_ENDIAN_SELECT(le, be)        le
 545 #define LJ_ENDIAN_LOHI(lo, hi)          lo hi
 546 #endif
 547 
 548 #if LJ_ARCH_BITS == 32
 549 #define LJ_32                   1
 550 #define LJ_64                   0
 551 #else
 552 #define LJ_32                   0
 553 #define LJ_64                   1
 554 #endif
 555 
 556 #ifndef LJ_TARGET_UNALIGNED
 557 #define LJ_TARGET_UNALIGNED     0
 558 #endif
 559 
 560 /* Various workarounds for embedded operating systems or weak C runtimes. */
 561 #if defined(__ANDROID__) || defined(__symbian__) || LJ_TARGET_XBOX360 || LJ_TARGET_WINDOWS
 562 #define LUAJIT_NO_LOG2
 563 #endif
 564 #if defined(__symbian__) || LJ_TARGET_WINDOWS
 565 #define LUAJIT_NO_EXP2
 566 #endif
 567 #if LJ_TARGET_CONSOLE || (LJ_TARGET_IOS && __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0)
 568 #define LJ_NO_SYSTEM            1
 569 #endif
 570 
 571 #if !defined(LUAJIT_NO_UNWIND) && __GNU_COMPACT_EH__
 572 /* NYI: no support for compact unwind specification, yet. */
 573 #define LUAJIT_NO_UNWIND        1
 574 #endif
 575 
 576 #if defined(LUAJIT_NO_UNWIND) || defined(__symbian__) || LJ_TARGET_IOS || LJ_TARGET_PS3 || LJ_TARGET_PS4
 577 #define LJ_NO_UNWIND            1
 578 #endif
 579 
 580 #if LJ_TARGET_WINDOWS
 581 #if LJ_TARGET_UWP
 582 #define LJ_WIN_VALLOC   VirtualAllocFromApp
 583 #define LJ_WIN_VPROTECT VirtualProtectFromApp
 584 extern void *LJ_WIN_LOADLIBA(const char *path);
 585 #else
 586 #define LJ_WIN_VALLOC   VirtualAlloc
 587 #define LJ_WIN_VPROTECT VirtualProtect
 588 #define LJ_WIN_LOADLIBA(path)   LoadLibraryExA((path), NULL, 0)
 589 #endif
 590 #endif
 591 
 592 /* Compatibility with Lua 5.1 vs. 5.2. */
 593 #ifdef LUAJIT_ENABLE_LUA52COMPAT
 594 #define LJ_52                   1
 595 #else
 596 #define LJ_52                   0
 597 #endif
 598 
 599 #endif

/* [<][>][^][v][top][bottom][index][help] */