summaryrefslogtreecommitdiffstats
path: root/Include/cpython/code.h
diff options
context:
space:
mode:
authorBrandt Bucher <brandtbucher@microsoft.com>2022-03-12 00:31:50 (GMT)
committerGitHub <noreply@github.com>2022-03-12 00:31:50 (GMT)
commita89c29fbcc7e7e85848499443d819c3fab68c78a (patch)
tree76acc3e4a6d197b98e96cf74ac4b04a917e1bb5b /Include/cpython/code.h
parent882d8096c262a5945e0cfdd706e5db3ad2b73543 (diff)
downloadcpython-a89c29fbcc7e7e85848499443d819c3fab68c78a.zip
cpython-a89c29fbcc7e7e85848499443d819c3fab68c78a.tar.gz
cpython-a89c29fbcc7e7e85848499443d819c3fab68c78a.tar.bz2
bpo-46841: Add a _Py_SET_OPCODE macro (GH-31780)
Diffstat (limited to 'Include/cpython/code.h')
-rw-r--r--Include/cpython/code.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/Include/cpython/code.h b/Include/cpython/code.h
index f3e0761..ab827c5 100644
--- a/Include/cpython/code.h
+++ b/Include/cpython/code.h
@@ -23,6 +23,9 @@ typedef uint16_t _Py_CODEUNIT;
# define _Py_MAKECODEUNIT(opcode, oparg) ((opcode)|((oparg)<<8))
#endif
+// Use "unsigned char" instead of "uint8_t" here to avoid illegal aliasing:
+#define _Py_SET_OPCODE(word, opcode) (((unsigned char *)&(word))[0] = (opcode))
+
/* Bytecode object */
struct PyCodeObject {