| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7d896ab commit 1a8791e
12 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,6 +54,11 @@ int PyImport_ImportFrozenModule Py_PROTO((char *)); | |||
| 54 | 54 | extern PyObject *_PyImport_FindExtension Py_PROTO((char *, char *)); | |
| 55 | 55 | extern PyObject *_PyImport_FixupExtension Py_PROTO((char *, char *)); | |
| 56 | 56 | ||
| 57 | + #ifdef __BEOS__ | ||
| 58 | + #include <kernel/image.h> | ||
| 59 | + extern image_id PyImport_BeImageID( char *name ); | ||
| 60 | + #endif | ||
| 61 | + | ||
| 57 | 62 | struct _inittab { | |
| 58 | 63 | char *name; | |
| 59 | 64 | void (*initfunc)(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,6 +50,13 @@ extern long PyLong_AsLong Py_PROTO((PyObject *)); | |||
| 50 | 50 | extern unsigned long PyLong_AsUnsignedLong Py_PROTO((PyObject *)); | |
| 51 | 51 | extern double PyLong_AsDouble Py_PROTO((PyObject *)); | |
| 52 | 52 | ||
| 53 | + #ifdef HAVE_LONG_LONG | ||
| 54 | + extern PyObject *PyLong_FromLongLong Py_PROTO((long long )); | ||
| 55 | + extern PyObject *PyLong_FromUnsignedLongLong Py_PROTO((unsigned long long)); | ||
| 56 | + extern long long PyLong_AsLongLong Py_PROTO((PyObject *)); | ||
| 57 | + extern unsigned long long PyLong_AsUnsignedLongLong Py_PROTO((PyObject *)); | ||
| 58 | + #endif | ||
| 59 | + | ||
| 53 | 60 | PyObject *PyLong_FromString Py_PROTO((char *, char **, int)); | |
| 54 | 61 | ||
| 55 | 62 | #ifdef __cplusplus | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,10 +20,17 @@ extern "C" { | |||
| 20 | 20 | #endif | |
| 21 | 21 | ||
| 22 | 22 | /* Macros defining new names for all these symbols */ | |
| 23 | + /* BeOS note: We have exit_thread(), and no legacy code to | ||
| 24 | + * support, so we won't allow exit_thread and _exit_thread | ||
| 25 | + * in here. Actually, I think these #defines should vanish; | ||
| 26 | + * aren't they cheesy in the face of the Great Renaming? [cjh] | ||
| 27 | + */ | ||
| 23 | 28 | #define init_thread PyThread_init_thread | |
| 24 | 29 | #define start_new_thread PyThread_start_new_thread | |
| 30 | + #ifndef __BEOS__ | ||
| 25 | 31 | #define exit_thread PyThread_exit_thread | |
| 26 | 32 | #define _exit_thread PyThread__exit_thread | |
| 33 | + #endif | ||
| 27 | 34 | #define get_thread_ident PyThread_get_thread_ident | |
| 28 | 35 | #define allocate_lock PyThread_allocate_lock | |
| 29 | 36 | #define free_lock PyThread_free_lock | |
@@ -43,8 +50,13 @@ extern "C" { | |||
| 43 | 50 | ||
| 44 | 51 | void init_thread Py_PROTO((void)); | |
| 45 | 52 | int start_new_thread Py_PROTO((void (*)(void *), void *)); | |
| 53 | + #ifndef __BEOS__ | ||
| 46 | 54 | void exit_thread Py_PROTO((void)); | |
| 47 | 55 | void _exit_thread Py_PROTO((void)); | |
| 56 | + #else | ||
| 57 | + void PyThread_exit_thread Py_PROTO((void)); | ||
| 58 | + void PyThread__exit_thread Py_PROTO((void)); | ||
| 59 | + #endif | ||
| 48 | 60 | long get_thread_ident Py_PROTO((void)); | |
| 49 | 61 | ||
| 50 | 62 | type_lock allocate_lock Py_PROTO((void)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,10 +20,17 @@ extern "C" { | |||
| 20 | 20 | #endif | |
| 21 | 21 | ||
| 22 | 22 | /* Macros defining new names for all these symbols */ | |
| 23 | + /* BeOS note: We have exit_thread(), and no legacy code to | ||
| 24 | + * support, so we won't allow exit_thread and _exit_thread | ||
| 25 | + * in here. Actually, I think these #defines should vanish; | ||
| 26 | + * aren't they cheesy in the face of the Great Renaming? [cjh] | ||
| 27 | + */ | ||
| 23 | 28 | #define init_thread PyThread_init_thread | |
| 24 | 29 | #define start_new_thread PyThread_start_new_thread | |
| 30 | + #ifndef __BEOS__ | ||
| 25 | 31 | #define exit_thread PyThread_exit_thread | |
| 26 | 32 | #define _exit_thread PyThread__exit_thread | |
| 33 | + #endif | ||
| 27 | 34 | #define get_thread_ident PyThread_get_thread_ident | |
| 28 | 35 | #define allocate_lock PyThread_allocate_lock | |
| 29 | 36 | #define free_lock PyThread_free_lock | |
@@ -43,8 +50,13 @@ extern "C" { | |||
| 43 | 50 | ||
| 44 | 51 | void init_thread Py_PROTO((void)); | |
| 45 | 52 | int start_new_thread Py_PROTO((void (*)(void *), void *)); | |
| 53 | + #ifndef __BEOS__ | ||
| 46 | 54 | void exit_thread Py_PROTO((void)); | |
| 47 | 55 | void _exit_thread Py_PROTO((void)); | |
| 56 | + #else | ||
| 57 | + void PyThread_exit_thread Py_PROTO((void)); | ||
| 58 | + void PyThread__exit_thread Py_PROTO((void)); | ||
| 59 | + #endif | ||
| 48 | 60 | long get_thread_ident Py_PROTO((void)); | |
| 49 | 61 | ||
| 50 | 62 | type_lock allocate_lock Py_PROTO((void)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -277,6 +277,198 @@ PyLong_AsDouble(vv) | |||
| 277 | 277 | return x * sign; | |
| 278 | 278 | } | |
| 279 | 279 | ||
| 280 | + #ifdef HAVE_LONG_LONG | ||
| 281 | + /* | ||
| 282 | + * long long support by Chris Herborth (chrish@qnx.com) | ||
| 283 | + * | ||
| 284 | + * For better or worse :-), I tried to follow the coding style already | ||
| 285 | + * here. | ||
| 286 | + */ | ||
| 287 | + | ||
| 288 | + #ifdef HAVE_LIMITS_H | ||
| 289 | + #include <limits.h> | ||
| 290 | + #endif | ||
| 291 | + | ||
| 292 | + /* Hopefully this is portable... */ | ||
| 293 | + #ifndef LONG_MAX | ||
| 294 | + #define LONG_MAX 2147483647L | ||
| 295 | + #endif | ||
| 296 | + #ifndef ULONG_MAX | ||
| 297 | + #define ULONG_MAX 4294967295U | ||
| 298 | + #endif | ||
| 299 | + #ifndef LONGLONG_MAX | ||
| 300 | + #define LONGLONG_MAX 9223372036854775807LL | ||
| 301 | + #endif | ||
| 302 | + #ifndef ULONGLONG_MAX | ||
| 303 | + #define ULONGLONG_MAX 0xffffffffffffffffULL | ||
| 304 | + #endif | ||
| 305 | + | ||
| 306 | + /* Create a new long int object from a C long long int */ | ||
| 307 | + | ||
| 308 | + PyObject * | ||
| 309 | + PyLong_FromLongLong(ival) | ||
| 310 | + long long ival; | ||
| 311 | + { | ||
| 312 | + #if SIZEOF_LONG_LONG == SIZEOF_LONG | ||
| 313 | + /* In case the compiler is faking it. */ | ||
| 314 | + return PyLong_FromLong( (long)ival ); | ||
| 315 | + #else | ||
| 316 | + if( ival <= (long long)LONG_MAX ) { | ||
| 317 | + return PyLong_FromLong( (long)ival ); | ||
| 318 | + } else if( ival <= (unsigned long long)ULONG_MAX ) { | ||
| 319 | + return PyLong_FromUnsignedLong( (unsigned long)ival ); | ||
| 320 | + } else { | ||
| 321 | + /* Assume a C long long fits in at most 10 'digits'. | ||
| 322 | + * Should be OK if we're assuming long fits in 5. | ||
| 323 | + */ | ||
| 324 | + PyLongObject *v = _PyLong_New(10); | ||
| 325 | + | ||
| 326 | + if (v != NULL) { | ||
| 327 | + unsigned long long t = ival; | ||
| 328 | + int i; | ||
| 329 | + if (ival < 0) { | ||
| 330 | + t = -ival; | ||
| 331 | + v->ob_size = -(v->ob_size); | ||
| 332 | + } | ||
| 333 | + | ||
| 334 | + for (i = 0; i < 10; i++) { | ||
| 335 | + v->ob_digit[i] = (digit) (t & MASK); | ||
| 336 | + t >>= SHIFT; | ||
| 337 | + } | ||
| 338 | + | ||
| 339 | + v = long_normalize(v); | ||
| 340 | + } | ||
| 341 | + | ||
| 342 | + return (PyObject *)v; | ||
| 343 | + } | ||
| 344 | + | ||
| 345 | + /* If we got here, we're confused... */ | ||
| 346 | + PyErr_SetString( PyExc_ArithmeticError, "invalid long integer" ); | ||
| 347 | + return NULL; | ||
| 348 | + #endif | ||
| 349 | + } | ||
| 350 | + | ||
| 351 | + /* Create a new long int object from a C unsigned long long int */ | ||
| 352 | + PyObject * | ||
| 353 | + PyLong_FromUnsignedLongLong(ival) | ||
| 354 | + unsigned long long ival; | ||
| 355 | + { | ||
| 356 | + #if SIZEOF_LONG_LONG == SIZEOF_LONG | ||
| 357 | + /* In case the compiler is faking it. */ | ||
| 358 | + return PyLong_FromUnsignedLong( (unsigned long)ival ); | ||
| 359 | + #else | ||
| 360 | + if( ival <= (unsigned long long)ULONG_MAX ) { | ||
| 361 | + return PyLong_FromUnsignedLong( (unsigned long)ival ); | ||
| 362 | + } else { | ||
| 363 | + /* Assume a C long fits in at most 10 'digits'. */ | ||
| 364 | + PyLongObject *v = _PyLong_New(10); | ||
| 365 | + | ||
| 366 | + if (v != NULL) { | ||
| 367 | + unsigned long long t = ival; | ||
| 368 | + int i; | ||
| 369 | + for (i = 0; i < 10; i++) { | ||
| 370 | + v->ob_digit[i] = (digit) (t & MASK); | ||
| 371 | + t >>= SHIFT; | ||
| 372 | + } | ||
| 373 | + | ||
| 374 | + v = long_normalize(v); | ||
| 375 | + } | ||
| 376 | + | ||
| 377 | + return (PyObject *)v; | ||
| 378 | + } | ||
| 379 | + | ||
| 380 | + /* If we got here, we're confused... */ | ||
| 381 | + PyErr_SetString( PyExc_ArithmeticError, "invalid unsigned long integer" ); | ||
| 382 | + return NULL; | ||
| 383 | + #endif | ||
| 384 | + } | ||
| 385 | + | ||
| 386 | + /* Get a C long long int from a long int object. | ||
| 387 | + Returns -1 and sets an error condition if overflow occurs. */ | ||
| 388 | + | ||
| 389 | + long long | ||
| 390 | + PyLong_AsLongLong(vv) | ||
| 391 | + PyObject *vv; | ||
| 392 | + { | ||
| 393 | + #if SIZEOF_LONG_LONG == SIZEOF_LONG | ||
| 394 | + /* In case the compiler is faking it. */ | ||
| 395 | + return (long long)PyLong_AsLong( vv ); | ||
| 396 | + #else | ||
| 397 | + register PyLongObject *v; | ||
| 398 | + long long x, prev; | ||
| 399 | + int i, sign; | ||
| 400 | + | ||
| 401 | + if (vv == NULL || !PyLong_Check(vv)) { | ||
| 402 | + PyErr_BadInternalCall(); | ||
| 403 | + return -1; | ||
| 404 | + } | ||
| 405 | + | ||
| 406 | + v = (PyLongObject *)vv; | ||
| 407 | + i = v->ob_size; | ||
| 408 | + sign = 1; | ||
| 409 | + x = 0; | ||
| 410 | + | ||
| 411 | + if (i < 0) { | ||
| 412 | + sign = -1; | ||
| 413 | + i = -(i); | ||
| 414 | + } | ||
| 415 | + | ||
| 416 | + while (--i >= 0) { | ||
| 417 | + prev = x; | ||
| 418 | + x = (x << SHIFT) + v->ob_digit[i]; | ||
| 419 | + if ((x >> SHIFT) != prev) { | ||
| 420 | + PyErr_SetString(PyExc_OverflowError, | ||
| 421 | + "long int too long to convert"); | ||
| 422 | + return -1; | ||
| 423 | + } | ||
| 424 | + } | ||
| 425 | + | ||
| 426 | + return x * sign; | ||
| 427 | + #endif | ||
| 428 | + } | ||
| 429 | + | ||
| 430 | + unsigned long long | ||
| 431 | + PyLong_AsUnsignedLongLong(vv) | ||
| 432 | + PyObject *vv; | ||
| 433 | + { | ||
| 434 | + #if SIZEOF_LONG_LONG == 4 | ||
| 435 | + /* In case the compiler is faking it. */ | ||
| 436 | + return (unsigned long long)PyLong_AsUnsignedLong( vv ); | ||
| 437 | + #else | ||
| 438 | + register PyLongObject *v; | ||
| 439 | + unsigned long long x, prev; | ||
| 440 | + int i; | ||
| 441 | + | ||
| 442 | + if (vv == NULL || !PyLong_Check(vv)) { | ||
| 443 | + PyErr_BadInternalCall(); | ||
| 444 | + return (unsigned long long) -1; | ||
| 445 | + } | ||
| 446 | + | ||
| 447 | + v = (PyLongObject *)vv; | ||
| 448 | + i = v->ob_size; | ||
| 449 | + x = 0; | ||
| 450 | + | ||
| 451 | + if (i < 0) { | ||
| 452 | + PyErr_SetString(PyExc_OverflowError, | ||
| 453 | + "can't convert negative value to unsigned long"); | ||
| 454 | + return (unsigned long long) -1; | ||
| 455 | + } | ||
| 456 | + | ||
| 457 | + while (--i >= 0) { | ||
| 458 | + prev = x; | ||
| 459 | + x = (x << SHIFT) + v->ob_digit[i]; | ||
| 460 | + if ((x >> SHIFT) != prev) { | ||
| 461 | + PyErr_SetString(PyExc_OverflowError, | ||
| 462 | + "long int too long to convert"); | ||
| 463 | + return (unsigned long long) -1; | ||
| 464 | + } | ||
| 465 | + } | ||
| 466 | + | ||
| 467 | + return x; | ||
| 468 | + #endif | ||
| 469 | + } | ||
| 470 | + #endif /* HAVE_LONG_LONG */ | ||
| 471 | + | ||
| 280 | 472 | /* Multiply by a single digit, ignoring the sign. */ | |
| 281 | 473 | ||
| 282 | 474 | static PyLongObject * | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,6 +42,11 @@ extern void PyWinFreeze_ExeTerm(); | |||
| 42 | 42 | #include <unistd.h> /* For isatty() */ | |
| 43 | 43 | #endif | |
| 44 | 44 | ||
| 45 | + /* For isatty()'s proto. - [cjh] */ | ||
| 46 | + #ifdef HAVE_UNISTD_H | ||
| 47 | + #include <unistd.h> | ||
| 48 | + #endif | ||
| 49 | + | ||
| 45 | 50 | /* Main program */ | |
| 46 | 51 | ||
| 47 | 52 | int | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -499,6 +499,20 @@ convertsimple1(arg, p_format, p_va) | |||
| 499 | 499 | break; | |
| 500 | 500 | } | |
| 501 | 501 | ||
| 502 | + #if HAVE_LONG_LONG | ||
| 503 | + case 'L': /* long long */ | ||
| 504 | + { | ||
| 505 | + long long *p = va_arg( *p_va, long long * ); | ||
| 506 | + long long ival = PyLong_AsLongLong( arg ); | ||
| 507 | + if( ival == (long long)-1 && PyErr_Occurred() ) { | ||
| 508 | + return "long<L>"; | ||
| 509 | + } else { | ||
| 510 | + *p = ival; | ||
| 511 | + } | ||
| 512 | + break; | ||
| 513 | + } | ||
| 514 | + #endif | ||
| 515 | + | ||
| 502 | 516 | case 'f': /* float */ | |
| 503 | 517 | { | |
| 504 | 518 | float *p = va_arg(*p_va, float *); | |
@@ -988,6 +1002,14 @@ skipitem(p_format, p_va) | |||
| 988 | 1002 | break; | |
| 989 | 1003 | } | |
| 990 | 1004 | ||
| 1005 | + #if HAVE_LONG_LONG | ||
| 1006 | + case 'L': /* long long int */ | ||
| 1007 | + { | ||
| 1008 | + (void) va_arg(*p_va, long long *); | ||
| 1009 | + break; | ||
| 1010 | + } | ||
| 1011 | + #endif | ||
| 1012 | + | ||
| 991 | 1013 | case 'f': /* float */ | |
| 992 | 1014 | { | |
| 993 | 1015 | (void) va_arg(*p_va, float *); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2274,7 +2274,7 @@ static PyMethodDef imp_methods[] = { | |||
| 2274 | 2274 | {NULL, NULL} /* sentinel */ | |
| 2275 | 2275 | }; | |
| 2276 | 2276 | ||
| 2277 | - int | ||
| 2277 | + static int | ||
| 2278 | 2278 | setint(d, name, value) | |
| 2279 | 2279 | PyObject *d; | |
| 2280 | 2280 | char *name; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments