| 1 |
#ifndef Py_PYPORT_H |
| 2 |
#define Py_PYPORT_H |
| 3 |
|
| 4 |
#include "pyconfig.h" |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#ifdef HAVE_INTTYPES_H |
| 9 |
#include <inttypes.h> |
| 10 |
#endif |
| 11 |
|
| 12 |
#ifdef HAVE_STDINT_H |
| 13 |
#include <stdint.h> |
| 14 |
#endif |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
#ifdef HAVE_PROTOTYPES |
| 47 |
#define Py_PROTO(x) x |
| 48 |
#else |
| 49 |
#define Py_PROTO(x) () |
| 50 |
#endif |
| 51 |
#ifndef Py_FPROTO |
| 52 |
#define Py_FPROTO(x) Py_PROTO(x) |
| 53 |
#endif |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
#ifdef HAVE_LONG_LONG |
| 68 |
#ifndef PY_LONG_LONG |
| 69 |
#define PY_LONG_LONG long long |
| 70 |
#if defined(LLONG_MAX) |
| 71 |
|
| 72 |
#define PY_LLONG_MIN LLONG_MIN |
| 73 |
#define PY_LLONG_MAX LLONG_MAX |
| 74 |
#define PY_ULLONG_MAX ULLONG_MAX |
| 75 |
#elif defined(__LONG_LONG_MAX__) |
| 76 |
|
| 77 |
#define PY_LLONG_MAX __LONG_LONG_MAX__ |
| 78 |
#define PY_LLONG_MIN (-PY_LLONG_MAX-1) |
| 79 |
#define PY_ULLONG_MAX (__LONG_LONG_MAX__*2ULL + 1ULL) |
| 80 |
#else |
| 81 |
|
| 82 |
#define PY_ULLONG_MAX (~0ULL) |
| 83 |
#define PY_LLONG_MAX ((long long)(PY_ULLONG_MAX>>1)) |
| 84 |
#define PY_LLONG_MIN (-PY_LLONG_MAX-1) |
| 85 |
#endif |
| 86 |
#endif |
| 87 |
#endif |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
#ifdef uint32_t |
| 97 |
#define HAVE_UINT32_T 1 |
| 98 |
#endif |
| 99 |
|
| 100 |
#ifdef HAVE_UINT32_T |
| 101 |
#ifndef PY_UINT32_T |
| 102 |
#define PY_UINT32_T uint32_t |
| 103 |
#endif |
| 104 |
#endif |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
#ifdef uint64_t |
| 110 |
#define HAVE_UINT64_T 1 |
| 111 |
#endif |
| 112 |
|
| 113 |
#ifdef HAVE_UINT64_T |
| 114 |
#ifndef PY_UINT64_T |
| 115 |
#define PY_UINT64_T uint64_t |
| 116 |
#endif |
| 117 |
#endif |
| 118 |
|
| 119 |
|
| 120 |
#ifdef int32_t |
| 121 |
#define HAVE_INT32_T 1 |
| 122 |
#endif |
| 123 |
|
| 124 |
#ifdef HAVE_INT32_T |
| 125 |
#ifndef PY_INT32_T |
| 126 |
#define PY_INT32_T int32_t |
| 127 |
#endif |
| 128 |
#endif |
| 129 |
|
| 130 |
#ifdef int64_t |
| 131 |
#define HAVE_INT64_T 1 |
| 132 |
#endif |
| 133 |
|
| 134 |
#ifdef HAVE_INT64_T |
| 135 |
#ifndef PY_INT64_T |
| 136 |
#define PY_INT64_T int64_t |
| 137 |
#endif |
| 138 |
#endif |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
#ifndef PYLONG_BITS_IN_DIGIT |
| 145 |
#if (defined HAVE_UINT64_T && defined HAVE_INT64_T && \ |
| 146 |
defined HAVE_UINT32_T && defined HAVE_INT32_T && SIZEOF_VOID_P >= 8) |
| 147 |
#define PYLONG_BITS_IN_DIGIT 30 |
| 148 |
#else |
| 149 |
#define PYLONG_BITS_IN_DIGIT 15 |
| 150 |
#endif |
| 151 |
#endif |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
#ifdef HAVE_UINTPTR_T |
| 159 |
typedef uintptr_t Py_uintptr_t; |
| 160 |
typedef intptr_t Py_intptr_t; |
| 161 |
|
| 162 |
#elif SIZEOF_VOID_P <= SIZEOF_INT |
| 163 |
typedef unsigned int Py_uintptr_t; |
| 164 |
typedef int Py_intptr_t; |
| 165 |
|
| 166 |
#elif SIZEOF_VOID_P <= SIZEOF_LONG |
| 167 |
typedef unsigned long Py_uintptr_t; |
| 168 |
typedef long Py_intptr_t; |
| 169 |
|
| 170 |
#elif defined(HAVE_LONG_LONG) && (SIZEOF_VOID_P <= SIZEOF_LONG_LONG) |
| 171 |
typedef unsigned PY_LONG_LONG Py_uintptr_t; |
| 172 |
typedef PY_LONG_LONG Py_intptr_t; |
| 173 |
|
| 174 |
#else |
| 175 |
# error "Python needs a typedef for Py_uintptr_t in pyport.h." |
| 176 |
#endif |
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
#ifdef HAVE_SSIZE_T |
| 183 |
typedef ssize_t Py_ssize_t; |
| 184 |
#elif SIZEOF_VOID_P == SIZEOF_SIZE_T |
| 185 |
typedef Py_intptr_t Py_ssize_t; |
| 186 |
#else |
| 187 |
# error "Python needs a typedef for Py_ssize_t in pyport.h." |
| 188 |
#endif |
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
#ifdef SIZE_MAX |
| 196 |
#define PY_SIZE_MAX SIZE_MAX |
| 197 |
#else |
| 198 |
#define PY_SIZE_MAX ((size_t)-1) |
| 199 |
#endif |
| 200 |
|
| 201 |
|
| 202 |
#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1)) |
| 203 |
|
| 204 |
#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1) |
| 205 |
|
| 206 |
#if SIZEOF_PID_T > SIZEOF_LONG |
| 207 |
# error "Python doesn't support sizeof(pid_t) > sizeof(long)" |
| 208 |
#endif |
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
#ifndef PY_FORMAT_SIZE_T |
| 234 |
# if SIZEOF_SIZE_T == SIZEOF_INT && !defined(__APPLE__) |
| 235 |
# define PY_FORMAT_SIZE_T "" |
| 236 |
# elif SIZEOF_SIZE_T == SIZEOF_LONG |
| 237 |
# define PY_FORMAT_SIZE_T "l" |
| 238 |
# elif defined(MS_WINDOWS) |
| 239 |
# define PY_FORMAT_SIZE_T "I" |
| 240 |
# else |
| 241 |
# error "This platform's pyconfig.h needs to define PY_FORMAT_SIZE_T" |
| 242 |
# endif |
| 243 |
#endif |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
#ifdef HAVE_LONG_LONG |
| 252 |
# ifndef PY_FORMAT_LONG_LONG |
| 253 |
# if defined(MS_WIN64) || defined(MS_WINDOWS) |
| 254 |
# define PY_FORMAT_LONG_LONG "I64" |
| 255 |
# else |
| 256 |
# error "This platform's pyconfig.h needs to define PY_FORMAT_LONG_LONG" |
| 257 |
# endif |
| 258 |
# endif |
| 259 |
#endif |
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
#undef USE_INLINE |
| 279 |
|
| 280 |
#if defined(_MSC_VER) |
| 281 |
#if defined(PY_LOCAL_AGGRESSIVE) |
| 282 |
|
| 283 |
#pragma optimize("agtw", on) |
| 284 |
#endif |
| 285 |
|
| 286 |
#pragma warning(disable: 4710) |
| 287 |
|
| 288 |
#define Py_LOCAL(type) static type __fastcall |
| 289 |
#define Py_LOCAL_INLINE(type) static __inline type __fastcall |
| 290 |
#elif defined(USE_INLINE) |
| 291 |
#define Py_LOCAL(type) static type |
| 292 |
#define Py_LOCAL_INLINE(type) static inline type |
| 293 |
#else |
| 294 |
#define Py_LOCAL(type) static type |
| 295 |
#define Py_LOCAL_INLINE(type) static type |
| 296 |
#endif |
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
#if defined(_MSC_VER) |
| 305 |
#define Py_MEMCPY(target, source, length) do { \ |
| 306 |
size_t i_, n_ = (length); \ |
| 307 |
char *t_ = (void*) (target); \ |
| 308 |
const char *s_ = (void*) (source); \ |
| 309 |
if (n_ >= 16) \ |
| 310 |
memcpy(t_, s_, n_); \ |
| 311 |
else \ |
| 312 |
for (i_ = 0; i_ < n_; i_++) \ |
| 313 |
t_[i_] = s_[i_]; \ |
| 314 |
} while (0) |
| 315 |
#else |
| 316 |
#define Py_MEMCPY memcpy |
| 317 |
#endif |
| 318 |
|
| 319 |
#include <stdlib.h> |
| 320 |
|
| 321 |
#ifdef HAVE_IEEEFP_H |
| 322 |
#include <ieeefp.h> |
| 323 |
#endif |
| 324 |
|
| 325 |
#include <math.h> |
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
#ifdef TIME_WITH_SYS_TIME |
| 332 |
#include <sys/time.h> |
| 333 |
#include <time.h> |
| 334 |
#else |
| 335 |
#ifdef HAVE_SYS_TIME_H |
| 336 |
#include <sys/time.h> |
| 337 |
#else |
| 338 |
#include <time.h> |
| 339 |
#endif |
| 340 |
#endif |
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
#ifdef HAVE_SYS_SELECT_H |
| 350 |
|
| 351 |
#include <sys/select.h> |
| 352 |
|
| 353 |
#endif |
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
#ifndef DONT_HAVE_STAT |
| 374 |
#define HAVE_STAT |
| 375 |
#endif |
| 376 |
|
| 377 |
#ifndef DONT_HAVE_FSTAT |
| 378 |
#define HAVE_FSTAT |
| 379 |
#endif |
| 380 |
|
| 381 |
#ifdef RISCOS |
| 382 |
#include <sys/types.h> |
| 383 |
#include "unixstuff.h" |
| 384 |
#endif |
| 385 |
|
| 386 |
#ifdef HAVE_SYS_STAT_H |
| 387 |
#if defined(PYOS_OS2) && defined(PYCC_GCC) |
| 388 |
#include <sys/types.h> |
| 389 |
#endif |
| 390 |
#include <sys/stat.h> |
| 391 |
#elif defined(HAVE_STAT_H) |
| 392 |
#include <stat.h> |
| 393 |
#endif |
| 394 |
|
| 395 |
#if defined(PYCC_VACPP) |
| 396 |
|
| 397 |
#define S_IFMT (S_IFDIR|S_IFCHR|S_IFREG) |
| 398 |
#endif |
| 399 |
|
| 400 |
#ifndef S_ISREG |
| 401 |
#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG) |
| 402 |
#endif |
| 403 |
|
| 404 |
#ifndef S_ISDIR |
| 405 |
#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR) |
| 406 |
#endif |
| 407 |
|
| 408 |
|
| 409 |
#ifdef __cplusplus |
| 410 |
|
| 411 |
|
| 412 |
extern "C" { |
| 413 |
#endif |
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
#ifdef SIGNED_RIGHT_SHIFT_ZERO_FILLS |
| 435 |
#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) \ |
| 436 |
((I) < 0 ? -1-((-1-(I)) >> (J)) : (I) >> (J)) |
| 437 |
#else |
| 438 |
#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) ((I) >> (J)) |
| 439 |
#endif |
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
#define Py_FORCE_EXPANSION(X) X |
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
#ifdef Py_DEBUG |
| 455 |
#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) \ |
| 456 |
(assert((WIDE)(NARROW)(VALUE) == (VALUE)), (NARROW)(VALUE)) |
| 457 |
#else |
| 458 |
#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) (NARROW)(VALUE) |
| 459 |
#endif |
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
#if defined(__FreeBSD__) || defined(__OpenBSD__) || (defined(__hpux) && defined(__ia64)) |
| 471 |
#define _Py_SET_EDOM_FOR_NAN(X) if (isnan(X)) errno = EDOM; |
| 472 |
#else |
| 473 |
#define _Py_SET_EDOM_FOR_NAN(X) ; |
| 474 |
#endif |
| 475 |
#define Py_SET_ERRNO_ON_MATH_ERROR(X) \ |
| 476 |
do { \ |
| 477 |
if (errno == 0) { \ |
| 478 |
if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \ |
| 479 |
errno = ERANGE; \ |
| 480 |
else _Py_SET_EDOM_FOR_NAN(X) \ |
| 481 |
} \ |
| 482 |
} while(0) |
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
#define Py_SET_ERANGE_IF_OVERFLOW(X) Py_SET_ERRNO_ON_MATH_ERROR(X) |
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
#define Py_ADJUST_ERANGE1(X) \ |
| 504 |
do { \ |
| 505 |
if (errno == 0) { \ |
| 506 |
if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \ |
| 507 |
errno = ERANGE; \ |
| 508 |
} \ |
| 509 |
else if (errno == ERANGE && (X) == 0.0) \ |
| 510 |
errno = 0; \ |
| 511 |
} while(0) |
| 512 |
|
| 513 |
#define Py_ADJUST_ERANGE2(X, Y) \ |
| 514 |
do { \ |
| 515 |
if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL || \ |
| 516 |
(Y) == Py_HUGE_VAL || (Y) == -Py_HUGE_VAL) { \ |
| 517 |
if (errno == 0) \ |
| 518 |
errno = ERANGE; \ |
| 519 |
} \ |
| 520 |
else if (errno == ERANGE) \ |
| 521 |
errno = 0; \ |
| 522 |
} while(0) |
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
#ifdef HAVE_GCC_ASM_FOR_X87 |
| 549 |
#define HAVE_PY_SET_53BIT_PRECISION 1 |
| 550 |
|
| 551 |
#define _Py_SET_53BIT_PRECISION_HEADER \ |
| 552 |
unsigned short old_387controlword, new_387controlword |
| 553 |
#define _Py_SET_53BIT_PRECISION_START \ |
| 554 |
do { \ |
| 555 |
old_387controlword = _Py_get_387controlword(); \ |
| 556 |
new_387controlword = (old_387controlword & ~0x0f00) | 0x0200; \ |
| 557 |
if (new_387controlword != old_387controlword) \ |
| 558 |
_Py_set_387controlword(new_387controlword); \ |
| 559 |
} while (0) |
| 560 |
#define _Py_SET_53BIT_PRECISION_END \ |
| 561 |
if (new_387controlword != old_387controlword) \ |
| 562 |
_Py_set_387controlword(old_387controlword) |
| 563 |
#endif |
| 564 |
|
| 565 |
|
| 566 |
#if defined(_MSC_VER) && !defined(_WIN64) |
| 567 |
#define HAVE_PY_SET_53BIT_PRECISION 1 |
| 568 |
#define _Py_SET_53BIT_PRECISION_HEADER \ |
| 569 |
unsigned int old_387controlword, new_387controlword, out_387controlword |
| 570 |
|
| 571 |
|
| 572 |
#define _Py_SET_53BIT_PRECISION_START \ |
| 573 |
do { \ |
| 574 |
__control87_2(0, 0, &old_387controlword, NULL); \ |
| 575 |
new_387controlword = \ |
| 576 |
(old_387controlword & ~(_MCW_PC | _MCW_RC)) | (_PC_53 | _RC_NEAR); \ |
| 577 |
if (new_387controlword != old_387controlword) \ |
| 578 |
__control87_2(new_387controlword, _MCW_PC | _MCW_RC, \ |
| 579 |
&out_387controlword, NULL); \ |
| 580 |
} while (0) |
| 581 |
#define _Py_SET_53BIT_PRECISION_END \ |
| 582 |
do { \ |
| 583 |
if (new_387controlword != old_387controlword) \ |
| 584 |
__control87_2(old_387controlword, _MCW_PC | _MCW_RC, \ |
| 585 |
&out_387controlword, NULL); \ |
| 586 |
} while (0) |
| 587 |
#endif |
| 588 |
|
| 589 |
|
| 590 |
#ifndef HAVE_PY_SET_53BIT_PRECISION |
| 591 |
#define _Py_SET_53BIT_PRECISION_HEADER |
| 592 |
#define _Py_SET_53BIT_PRECISION_START |
| 593 |
#define _Py_SET_53BIT_PRECISION_END |
| 594 |
#endif |
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
#if !defined(DOUBLE_IS_LITTLE_ENDIAN_IEEE754) && \ |
| 609 |
!defined(DOUBLE_IS_BIG_ENDIAN_IEEE754) && \ |
| 610 |
!defined(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754) |
| 611 |
#define PY_NO_SHORT_FLOAT_REPR |
| 612 |
#endif |
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
#if defined(X87_DOUBLE_ROUNDING) && !defined(HAVE_PY_SET_53BIT_PRECISION) |
| 618 |
#define PY_NO_SHORT_FLOAT_REPR |
| 619 |
#endif |
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
#if defined(__GNUC__) && ((__GNUC__ >= 4) || \ |
| 629 |
(__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)) |
| 630 |
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__)) |
| 631 |
#else |
| 632 |
#define Py_DEPRECATED(VERSION_UNUSED) |
| 633 |
#endif |
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
#ifdef SOLARIS |
| 644 |
|
| 645 |
extern int gethostname(char *, int); |
| 646 |
#endif |
| 647 |
|
| 648 |
#ifdef __BEOS__ |
| 649 |
|
| 650 |
|
| 651 |
int shutdown( int, int ); |
| 652 |
#endif |
| 653 |
|
| 654 |
#ifdef HAVE__GETPTY |
| 655 |
#include <sys/types.h> |
| 656 |
extern char * _getpty(int *, int, mode_t, int); |
| 657 |
#endif |
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
#if defined(HAVE_SYS_TERMIO_H) && !defined(__hpux) |
| 663 |
#include <sys/termio.h> |
| 664 |
#endif |
| 665 |
|
| 666 |
#if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) |
| 667 |
#if !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) && !defined(HAVE_UTIL_H) |
| 668 |
|
| 669 |
|
| 670 |
#include <termios.h> |
| 671 |
extern int openpty(int *, int *, char *, struct termios *, struct winsize *); |
| 672 |
extern pid_t forkpty(int *, char *, struct termios *, struct winsize *); |
| 673 |
#endif |
| 674 |
#endif |
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
#if 0 |
| 683 |
|
| 684 |
|
| 685 |
extern int getrusage(); |
| 686 |
extern int getpagesize(); |
| 687 |
|
| 688 |
|
| 689 |
extern int fclose(FILE *); |
| 690 |
|
| 691 |
|
| 692 |
extern int fdatasync(int); |
| 693 |
#endif |
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
#ifdef __FreeBSD__ |
| 704 |
#include <osreldate.h> |
| 705 |
#if (__FreeBSD_version >= 500040 && __FreeBSD_version < 602113) || \ |
| 706 |
(__FreeBSD_version >= 700000 && __FreeBSD_version < 700054) || \ |
| 707 |
(__FreeBSD_version >= 800000 && __FreeBSD_version < 800001) |
| 708 |
# define _PY_PORT_CTYPE_UTF8_ISSUE |
| 709 |
#endif |
| 710 |
#endif |
| 711 |
|
| 712 |
|
| 713 |
#if defined(__APPLE__) |
| 714 |
# define _PY_PORT_CTYPE_UTF8_ISSUE |
| 715 |
#endif |
| 716 |
|
| 717 |
#ifdef _PY_PORT_CTYPE_UTF8_ISSUE |
| 718 |
#ifndef __cplusplus |
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
#include <ctype.h> |
| 725 |
#include <wctype.h> |
| 726 |
#undef isalnum |
| 727 |
#define isalnum(c) iswalnum(btowc(c)) |
| 728 |
#undef isalpha |
| 729 |
#define isalpha(c) iswalpha(btowc(c)) |
| 730 |
#undef islower |
| 731 |
#define islower(c) iswlower(btowc(c)) |
| 732 |
#undef isspace |
| 733 |
#define isspace(c) iswspace(btowc(c)) |
| 734 |
#undef isupper |
| 735 |
#define isupper(c) iswupper(btowc(c)) |
| 736 |
#undef tolower |
| 737 |
#define tolower(c) towlower(btowc(c)) |
| 738 |
#undef toupper |
| 739 |
#define toupper(c) towupper(btowc(c)) |
| 740 |
#endif |
| 741 |
#endif |
| 742 |
|
| 743 |
|
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
#if defined(__CYGWIN__) || defined(__BEOS__) |
| 764 |
# define HAVE_DECLSPEC_DLL |
| 765 |
#endif |
| 766 |
|
| 767 |
|
| 768 |
#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__) |
| 769 |
# if defined(HAVE_DECLSPEC_DLL) |
| 770 |
# ifdef Py_BUILD_CORE |
| 771 |
# define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE |
| 772 |
# define PyAPI_DATA(RTYPE) extern __declspec(dllexport) RTYPE |
| 773 |
|
| 774 |
|
| 775 |
# if defined(__CYGWIN__) |
| 776 |
# define PyMODINIT_FUNC __declspec(dllexport) void |
| 777 |
# else |
| 778 |
# define PyMODINIT_FUNC void |
| 779 |
# endif |
| 780 |
# else |
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
# if !defined(__CYGWIN__) |
| 787 |
# define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE |
| 788 |
# endif |
| 789 |
# define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE |
| 790 |
|
| 791 |
# if defined(__cplusplus) |
| 792 |
# define PyMODINIT_FUNC extern "C" __declspec(dllexport) void |
| 793 |
# else |
| 794 |
# define PyMODINIT_FUNC __declspec(dllexport) void |
| 795 |
# endif |
| 796 |
# endif |
| 797 |
# endif |
| 798 |
#endif |
| 799 |
|
| 800 |
|
| 801 |
#ifndef PyAPI_FUNC |
| 802 |
# define PyAPI_FUNC(RTYPE) RTYPE |
| 803 |
#endif |
| 804 |
#ifndef PyAPI_DATA |
| 805 |
# define PyAPI_DATA(RTYPE) extern RTYPE |
| 806 |
#endif |
| 807 |
#ifndef PyMODINIT_FUNC |
| 808 |
# if defined(__cplusplus) |
| 809 |
# define PyMODINIT_FUNC extern "C" void |
| 810 |
# else |
| 811 |
# define PyMODINIT_FUNC void |
| 812 |
# endif |
| 813 |
#endif |
| 814 |
|
| 815 |
|
| 816 |
#if defined(Py_ENABLE_SHARED) && defined (HAVE_DECLSPEC_DLL) |
| 817 |
# if defined(Py_BUILD_CORE) |
| 818 |
# define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE |
| 819 |
# define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE |
| 820 |
# else |
| 821 |
# define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE |
| 822 |
# define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE |
| 823 |
# endif |
| 824 |
#endif |
| 825 |
#ifndef DL_EXPORT |
| 826 |
# define DL_EXPORT(RTYPE) RTYPE |
| 827 |
#endif |
| 828 |
#ifndef DL_IMPORT |
| 829 |
# define DL_IMPORT(RTYPE) RTYPE |
| 830 |
#endif |
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
|
| 835 |
|
| 836 |
#if 0 |
| 837 |
|
| 838 |
#ifndef FD_SETSIZE |
| 839 |
#define FD_SETSIZE 256 |
| 840 |
#endif |
| 841 |
|
| 842 |
#ifndef FD_SET |
| 843 |
|
| 844 |
typedef long fd_mask; |
| 845 |
|
| 846 |
#define NFDBITS (sizeof(fd_mask) * NBBY) |
| 847 |
#ifndef howmany |
| 848 |
#define howmany(x, y) (((x)+((y)-1))/(y)) |
| 849 |
#endif |
| 850 |
|
| 851 |
typedef struct fd_set { |
| 852 |
fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; |
| 853 |
} fd_set; |
| 854 |
|
| 855 |
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) |
| 856 |
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) |
| 857 |
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) |
| 858 |
#define FD_ZERO(p) memset((char *)(p), '\0', sizeof(*(p))) |
| 859 |
|
| 860 |
#endif |
| 861 |
|
| 862 |
#endif |
| 863 |
|
| 864 |
|
| 865 |
|
| 866 |
|
| 867 |
#ifndef INT_MAX |
| 868 |
#define INT_MAX 2147483647 |
| 869 |
#endif |
| 870 |
|
| 871 |
#ifndef LONG_MAX |
| 872 |
#if SIZEOF_LONG == 4 |
| 873 |
#define LONG_MAX 0X7FFFFFFFL |
| 874 |
#elif SIZEOF_LONG == 8 |
| 875 |
#define LONG_MAX 0X7FFFFFFFFFFFFFFFL |
| 876 |
#else |
| 877 |
#error "could not set LONG_MAX in pyport.h" |
| 878 |
#endif |
| 879 |
#endif |
| 880 |
|
| 881 |
#ifndef LONG_MIN |
| 882 |
#define LONG_MIN (-LONG_MAX-1) |
| 883 |
#endif |
| 884 |
|
| 885 |
#ifndef LONG_BIT |
| 886 |
#define LONG_BIT (8 * SIZEOF_LONG) |
| 887 |
#endif |
| 888 |
|
| 889 |
#if LONG_BIT != 8 * SIZEOF_LONG |
| 890 |
|
| 891 |
|
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)." |
| 896 |
#endif |
| 897 |
|
| 898 |
#ifdef __cplusplus |
| 899 |
} |
| 900 |
#endif |
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
#if (!defined(__GNUC__) || __GNUC__ < 2 || \ |
| 906 |
(__GNUC__ == 2 && __GNUC_MINOR__ < 7) ) && \ |
| 907 |
!defined(RISCOS) |
| 908 |
#define Py_GCC_ATTRIBUTE(x) |
| 909 |
#else |
| 910 |
#define Py_GCC_ATTRIBUTE(x) __attribute__(x) |
| 911 |
#endif |
| 912 |
|
| 913 |
|
| 914 |
|
| 915 |
|
| 916 |
#ifdef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE |
| 917 |
#define Py_FORMAT_PARSETUPLE(func,p1,p2) __attribute__((format(func,p1,p2))) |
| 918 |
#else |
| 919 |
#define Py_FORMAT_PARSETUPLE(func,p1,p2) |
| 920 |
#endif |
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
#if defined(__GNUC__) && __GNUC__ >= 3 |
| 926 |
#define Py_ALIGNED(x) __attribute__((aligned(x))) |
| 927 |
#else |
| 928 |
#define Py_ALIGNED(x) |
| 929 |
#endif |
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
#ifdef __SUNPRO_C |
| 935 |
#pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED) |
| 936 |
#endif |
| 937 |
|
| 938 |
|
| 939 |
|
| 940 |
|
| 941 |
|
| 942 |
#ifndef Py_LL |
| 943 |
#define Py_LL(x) x##LL |
| 944 |
#endif |
| 945 |
|
| 946 |
#ifndef Py_ULL |
| 947 |
#define Py_ULL(x) Py_LL(x##U) |
| 948 |
#endif |
| 949 |
|
| 950 |
#endif |