| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2bdc7f5 commit dfb866d
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,6 +48,7 @@ | |||
| 48 | 48 | #include <assert.h> | |
| 49 | 49 | ||
| 50 | 50 | #include "pyport.h" | |
| 51 | + #include "pymacro.h" | ||
| 51 | 52 | ||
| 52 | 53 | #include "pyatomic.h" | |
| 53 | 54 | ||
@@ -126,24 +127,6 @@ | |||
| 126 | 127 | #include "pystrcmp.h" | |
| 127 | 128 | #include "dtoa.h" | |
| 128 | 129 | #include "fileutils.h" | |
| 129 | - | ||
| 130 | - /* Argument must be a char or an int in [-128, 127] or [0, 255]. */ | ||
| 131 | - #define Py_CHARMASK(c) ((unsigned char)((c) & 0xff)) | ||
| 132 | - | ||
| 133 | 130 | #include "pyfpe.h" | |
| 134 | 131 | ||
| 135 | - /* Define macros for inline documentation. */ | ||
| 136 | - #define PyDoc_VAR(name) static char name[] | ||
| 137 | - #define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str) | ||
| 138 | - #ifdef WITH_DOC_STRINGS | ||
| 139 | - #define PyDoc_STR(str) str | ||
| 140 | - #else | ||
| 141 | - #define PyDoc_STR(str) "" | ||
| 142 | - #endif | ||
| 143 | - | ||
| 144 | - #define Py_ARRAY_LENGTH(array) (sizeof(array) / sizeof((array)[0])) | ||
| 145 | - | ||
| 146 | - #define Py_MIN(x, y) (((x) > (y)) ? (y) : (x)) | ||
| 147 | - #define Py_MAX(x, y) (((x) > (y)) ? (x) : (y)) | ||
| 148 | - | ||
| 149 | 132 | #endif /* !Py_PYTHON_H */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,57 @@ | |||
| 1 | + #ifndef Py_PYMACRO_H | ||
| 2 | + #define Py_PYMACRO_H | ||
| 3 | + | ||
| 4 | + #define Py_MIN(x, y) (((x) > (y)) ? (y) : (x)) | ||
| 5 | + #define Py_MAX(x, y) (((x) > (y)) ? (x) : (y)) | ||
| 6 | + | ||
| 7 | + /* Argument must be a char or an int in [-128, 127] or [0, 255]. */ | ||
| 8 | + #define Py_CHARMASK(c) ((unsigned char)((c) & 0xff)) | ||
| 9 | + | ||
| 10 | + | ||
| 11 | + /* Assert a build-time dependency, as an expression. | ||
| 12 | + | ||
| 13 | + Your compile will fail if the condition isn't true, or can't be evaluated | ||
| 14 | + by the compiler. This can be used in an expression: its value is 0. | ||
| 15 | + | ||
| 16 | + Example: | ||
| 17 | + | ||
| 18 | + #define foo_to_char(foo) \ | ||
| 19 | + ((char *)(foo) \ | ||
| 20 | + + Py_BUILD_ASSERT(offsetof(struct foo, string) == 0)) | ||
| 21 | + | ||
| 22 | + Written by Rusty Russell, public domain. */ | ||
| 23 | + #define Py_BUILD_ASSERT(cond) \ | ||
| 24 | + (sizeof(char [1 - 2*!(cond)]) - 1) | ||
| 25 | + | ||
| 26 | + #if defined(__GNUC__) | ||
| 27 | + /* Two gcc extensions. | ||
| 28 | + &a[0] degrades to a pointer: a different type from an array */ | ||
| 29 | + #define _Py_ARRAY_LENGTH_CHECK(array) \ | ||
| 30 | + Py_BUILD_ASSERT(!__builtin_types_compatible_p(typeof(array), \ | ||
| 31 | + typeof(&(array)[0]))) | ||
| 32 | + #else | ||
| 33 | + #define _Py_ARRAY_LENGTH_CHECK(array) 0 | ||
| 34 | + #endif | ||
| 35 | + | ||
| 36 | + | ||
| 37 | + /* Get the number of elements in a visible array | ||
| 38 | + | ||
| 39 | + This does not work on pointers, or arrays declared as [], or function | ||
| 40 | + parameters. With correct compiler support, such usage will cause a build | ||
| 41 | + error (see Py_BUILD_ASSERT). | ||
| 42 | + | ||
| 43 | + Written by Rusty Russell, public domain. */ | ||
| 44 | + #define Py_ARRAY_LENGTH(array) \ | ||
| 45 | + (sizeof(array) / sizeof((array)[0]) + _Py_ARRAY_LENGTH_CHECK(array)) | ||
| 46 | + | ||
| 47 | + | ||
| 48 | + /* Define macros for inline documentation. */ | ||
| 49 | + #define PyDoc_VAR(name) static char name[] | ||
| 50 | + #define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str) | ||
| 51 | + #ifdef WITH_DOC_STRINGS | ||
| 52 | + #define PyDoc_STR(str) str | ||
| 53 | + #else | ||
| 54 | + #define PyDoc_STR(str) "" | ||
| 55 | + #endif | ||
| 56 | + | ||
| 57 | + #endif /* Py_PYMACRO_H */ | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -493,7 +493,7 @@ $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \ | |||
| 493 | 493 | -install_name $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK) \ | |
| 494 | 494 | -compatibility_version $(VERSION) \ | |
| 495 | 495 | -current_version $(VERSION) \ | |
| 496 | - -framework CoreFoundation $(LIBS); | ||
| 496 | + -framework CoreFoundation $(LIBS); | ||
| 497 | 497 | $(INSTALL) -d -m $(DIRMODE) \ | |
| 498 | 498 | $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj | |
| 499 | 499 | $(INSTALL_DATA) $(RESSRCDIR)/Info.plist \ | |
@@ -718,6 +718,7 @@ PYTHON_HEADERS= \ | |||
| 718 | 718 | Include/pyfpe.h \ | |
| 719 | 719 | Include/pymath.h \ | |
| 720 | 720 | Include/pygetopt.h \ | |
| 721 | + Include/pymacro.h \ | ||
| 721 | 722 | Include/pymem.h \ | |
| 722 | 723 | Include/pyport.h \ | |
| 723 | 724 | Include/pystate.h \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -825,6 +825,7 @@ Rauli Ruohonen | |||
| 825 | 825 | Jeff Rush | |
| 826 | 826 | Sam Rushing | |
| 827 | 827 | Mark Russell | |
| 828 | + Rusty Russell | ||
| 828 | 829 | Nick Russo | |
| 829 | 830 | Patrick Sabin | |
| 830 | 831 | Sébastien Sablé | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -886,6 +886,10 @@ | |||
| 886 | 886 | RelativePath="..\Include\pytime.h" | |
| 887 | 887 | > | |
| 888 | 888 | </File> | |
| 889 | + <File | ||
| 890 | + RelativePath="..\Include\pymacro.h" | ||
| 891 | + > | ||
| 892 | + </File> | ||
| 889 | 893 | <File | |
| 890 | 894 | RelativePath="..\Include\pymem.h" | |
| 891 | 895 | > | |
| Back | FazBrowse Home | New Git URL |
0 commit comments