Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc07422d

Browse files
committed
Add ByteOrder.cpp
1 parent0d8f934 commitc07422d

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

‎Jamfile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ local sourceFiles =
199199
PrintJob.cpp
200200

201201
#SupportKit
202+
ByteOrder.cpp
202203
StopWatch.cpp
203204
Beep.cpp
204205
Locker.cpp

‎bindings/__init__.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
from .Inputimport*
9292
from .PrintJobimport*
9393

94+
from .ByteOrderimport*
9495
from .StopWatchimport*
9596
from .Beepimport*
9697
from .Architectureimport*

‎bindings/support/ByteOrder.cpp‎

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,33 @@
66
#include<support/ByteOrder.h>
77

88
namespacepy= pybind11;
9+
/*
10+
uint64 sw_int64(uint64 arg){
11+
#if __GNUC__ >= 4
12+
return __builtin_bswap64(arg);
13+
#else
14+
return __swap_int64(arg);
15+
}*/
916

17+
#if __GNUC__ >= 4
18+
uint64swap_int64(uint64 arg) {
19+
return__builtin_bswap64(arg);
20+
}
21+
uint32swap_int32(uint32 arg) {
22+
return__builtin_bswap32(arg);
23+
}
24+
uint16swap_int16(uint16 arg) {
25+
return__builtin_bswap16(arg);
26+
}
27+
#else
28+
extern uint64__swap_int64(uint64 arg);
29+
extern uint32__swap_int32(uint32 arg);
30+
extern uint16__swap_int16(uint16 arg);
31+
#endif
1032

11-
voiddefine_ByteOrder(py::module_& m)
33+
34+
35+
PYBIND11_MODULE(ByteOrder, m)
1236
{
1337
py::enum_<swap_action>(m,"swap_action","")
1438
.value("B_SWAP_HOST_TO_LENDIAN", swap_action::B_SWAP_HOST_TO_LENDIAN,"")
@@ -25,11 +49,18 @@ m.def("is_type_swapped", &is_type_swapped, "", py::arg("type"));
2549
m.def("__swap_double", &__swap_double,"",py::arg("arg"));
2650

2751
m.def("__swap_float", &__swap_float,"",py::arg("arg"));
28-
52+
/*
2953
m.def("__swap_int64", &__swap_int64, "", py::arg("arg"));
30-
3154
m.def("__swap_int32", &__swap_int32, "", py::arg("arg"));
32-
3355
m.def("__swap_int16", &__swap_int16, "", py::arg("arg"));
34-
56+
*/
57+
#if __GNUC__ >= 4
58+
m.def("__swap_int64", &swap_int64,"Swap bytes of a 64-bit integer");
59+
m.def("__swap_int32", &swap_int32,"Swap bytes of a 32-bit integer");
60+
m.def("__swap_int16", &swap_int16,"Swap bytes of a 16-bit integer");
61+
#else
62+
m.def("__swap_int64", &__swap_int64,"",py::arg("arg"));
63+
m.def("__swap_int32", &__swap_int32,"",py::arg("arg"));
64+
m.def("__swap_int16", &__swap_int16,"",py::arg("arg"));
65+
#endif
3566
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp