Add bswapr_us, bswapr_ui, and bswapr_ul API functions - lightning.git - Portable just-in-time compiler library

index : lightning.git
Portable just-in-time compiler library
summary refs log tree commit diff
path: root/check/lightning.c
diff options
context:
space:
mode:
authorPaul Cercueil <paul@crapouillou.net>2022年05月25日 19:18:20 +0100
committerpcpa <paulo.cesar.pereira.de.andrade@gmail.com>2022年05月25日 16:23:11 -0300
commitc44a80ca20ed534f4cf49e656bd9b7989633f4ea (patch)
treee7370910582f58cde22629f0a3ac68d09c337905 /check/lightning.c
parent44e8674a3aa32547b6161e2fb4212b7de2c0f707 (diff)
downloadlightning-c44a80ca20ed534f4cf49e656bd9b7989633f4ea.tar.gz
Add bswapr_us, bswapr_ui, and bswapr_ul API functions
The difference between bswapr and htonr/ntohr, is that the operation performed by bswap does not depend on the endianness of the host CPU. On little-endian however, the new bswapr functions are functionally equal to the htonr/ntohr ones. The implementations of the latter ones have then be removed, and will resolve to the corresponding bswapr function on little-endian, or to movr/extr functions on big-endian. Optional generic bswapr implementations are provided in lightning.c, which can be used (or not) by the arch cpu.c files when there's nothing better to do. The bswapr implementations are generally following the previous htonr implementations on little-endian systems, with the exception of the IA-64 architecture, where the htonr implementation seemed sub-par, and a better (yet untested) implementation has been added. This change has been tested on MIPS, x86 and PowerPC. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Diffstat (limited to 'check/lightning.c')
-rw-r--r--check/lightning.c 15
1 files changed, 15 insertions, 0 deletions
diff --git a/check/lightning.c b/check/lightning.c
index 9798a5b..3cf3e70 100644
--- a/check/lightning.c
+++ b/check/lightning.c
@@ -328,6 +328,11 @@ static void htonr_ui(void); static void ntohr_ui(void);
static void htonr_ul(void); static void ntohr_ul(void);
#endif
static void htonr(void); static void ntohr(void);
+static void bswapr_us(void); static void bswapr_ui(void);
+#if __WORDSIZE == 64
+static void bswapr_ul(void);
+#endif
+static void bswapr(void);
static void movnr(void); static void movzr(void);
static void ldr_c(void); static void ldi_c(void);
static void ldr_uc(void); static void ldi_uc(void);
@@ -643,6 +648,11 @@ static instr_t instr_vector[] = {
entry(htonr_ul), entry(ntohr_ul),
#endif
entry(htonr), entry(ntohr),
+ entry(bswapr_us), entry(bswapr_ui),
+#if __WORDSIZE == 64
+ entry(bswapr_ul),
+#endif
+ entry(bswapr),
entry(movnr), entry(movzr),
entry(ldr_c), entry(ldi_c),
entry(ldr_uc), entry(ldi_uc),
@@ -1492,6 +1502,11 @@ entry_ir_ir(htonr_ui) entry_ir_ir(ntohr_ui)
entry_ir_ir(htonr_ul) entry_ir_ir(ntohr_ul)
#endif
entry_ir_ir(htonr) entry_ir_ir(ntohr)
+entry_ir_ir(bswapr_us) entry_ir_ir(bswapr_ui)
+#if __WORDSIZE == 64
+entry_ir_ir(bswapr_ul)
+#endif
+entry_ir_ir(bswapr)
entry_ir_ir_ir(movnr) entry_ir_ir_ir(movzr)
entry_ir_ir(ldr_c) entry_ir_pm(ldi_c)
entry_ir_ir(ldr_uc) entry_ir_pm(ldi_uc)
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月15日 01:22:08 +0000

AltStyle によって変換されたページ (->オリジナル) /