Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
6a936edb
Commit
6a936edb
authored
2 years ago
by
Rob Swindell
Browse files
Options
Downloads
Patches
Plain Diff
Add support for non-native endian 64-bit integers
parent
c5ad7fc5
No related branches found
No related tags found
1 merge request
!463
MRC mods by Codefenix (2024-10-20)
Pipeline
#3138
passed
2 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sbbs3/js_file.c
+18
-2
18 additions, 2 deletions
src/sbbs3/js_file.c
src/xpdev/xpendian.h
+13
-1
13 additions, 1 deletion
src/xpdev/xpendian.h
with
31 additions
and
3 deletions
src/sbbs3/js_file.c
+
18
−
2
View file @
6a936edb
...
@@ -652,7 +652,11 @@ js_readbin(JSContext *cx, uintN argc, jsval *arglist)
...
@@ -652,7 +652,11 @@ js_readbin(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL
(
cx
,
arglist
,
UINT_TO_JSVAL
(
*
l
));
JS_SET_RVAL
(
cx
,
arglist
,
UINT_TO_JSVAL
(
*
l
));
break
;
break
;
case
sizeof
(
uint64_t
):
case
sizeof
(
uint64_t
):
JS_SET_RVAL
(
cx
,
arglist
,
DOUBLE_TO_JSVAL
(
*
q
));
if
(
p
->
network_byte_order
)
*
q
=
BE_INT64
(
*
q
);
else
*
q
=
LE_INT64
(
*
q
);
JS_SET_RVAL
(
cx
,
arglist
,
DOUBLE_TO_JSVAL
((
double
)
*
q
));
break
;
break
;
}
}
}
}
...
@@ -681,7 +685,11 @@ js_readbin(JSContext *cx, uintN argc, jsval *arglist)
...
@@ -681,7 +685,11 @@ js_readbin(JSContext *cx, uintN argc, jsval *arglist)
v
=
UINT_TO_JSVAL
(
*
(
l
++
));
v
=
UINT_TO_JSVAL
(
*
(
l
++
));
break
;
break
;
case
sizeof
(
uint64_t
):
case
sizeof
(
uint64_t
):
v
=
DOUBLE_TO_JSVAL
(
*
(
q
++
));
if
(
p
->
network_byte_order
)
*
q
=
BE_INT64
(
*
q
);
else
*
q
=
LE_INT64
(
*
q
);
v
=
DOUBLE_TO_JSVAL
((
double
)
*
(
q
++
));
break
;
break
;
}
}
if
(
!
JS_SetElement
(
cx
,
array
,
i
,
&
v
))
{
if
(
!
JS_SetElement
(
cx
,
array
,
i
,
&
v
))
{
...
@@ -1936,6 +1944,10 @@ js_writebin(JSContext *cx, uintN argc, jsval *arglist)
...
@@ -1936,6 +1944,10 @@ js_writebin(JSContext *cx, uintN argc, jsval *arglist)
*
o
.
sq
=
(
int64_t
)
val
;
*
o
.
sq
=
(
int64_t
)
val
;
else
else
*
o
.
q
=
(
uint64_t
)
val
;
*
o
.
q
=
(
uint64_t
)
val
;
if
(
p
->
network_byte_order
)
*
o
.
q
=
BE_INT64
(
*
o
.
q
);
else
*
o
.
q
=
LE_INT64
(
*
o
.
q
);
break
;
break
;
}
}
}
}
...
@@ -1980,6 +1992,10 @@ js_writebin(JSContext *cx, uintN argc, jsval *arglist)
...
@@ -1980,6 +1992,10 @@ js_writebin(JSContext *cx, uintN argc, jsval *arglist)
*
o
.
sq
=
(
int64_t
)
val
;
*
o
.
sq
=
(
int64_t
)
val
;
else
else
*
o
.
q
=
(
uint64_t
)
val
;
*
o
.
q
=
(
uint64_t
)
val
;
if
(
p
->
network_byte_order
)
*
o
.
q
=
BE_INT64
(
*
o
.
q
);
else
*
o
.
q
=
LE_INT64
(
*
o
.
q
);
o
.
q
++
;
o
.
q
++
;
break
;
break
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/xpdev/xpendian.h
+
13
−
1
View file @
6a936edb
...
@@ -29,9 +29,17 @@
...
@@ -29,9 +29,17 @@
/************************/
/************************/
#define BYTE_SWAP_16(x) ((((WORD)(x)&0xff00)>>8) | (((WORD)(x)&0x00ff)<<8))
#define BYTE_SWAP_16(x) ((((WORD)(x)&0xff00)>>8) | (((WORD)(x)&0x00ff)<<8))
#define BYTE_SWAP_32(x) ((((DWORD)(x)&0xff000000)>>24) | (((DWORD)(x)&0x00ff0000)>>8) | (((DWORD)(x)&0x0000ff00)<<8) | (((DWORD)(x)&0x000000ff)<<24))
#define BYTE_SWAP_32(x) ((((DWORD)(x)&0xff000000)>>24) | (((DWORD)(x)&0x00ff0000)>>8) | (((DWORD)(x)&0x0000ff00)<<8) | (((DWORD)(x)&0x000000ff)<<24))
#define BYTE_SWAP_64(x) ((((uint64_t)(x) & 0xff00000000000000ULL) >> 56) | \
( ((uint64_t)(x) & 0x00ff000000000000ULL) >> 40) | \
( ((uint64_t)(x) & 0x0000ff0000000000ULL) >> 24) | \
( ((uint64_t)(x) & 0x000000ff00000000ULL) >> 8) | \
( ((uint64_t)(x) & 0x00000000ff000000ULL) << 8) | \
( ((uint64_t)(x) & 0x0000000000ff0000ULL) << 24) | \
( ((uint64_t)(x) & 0x000000000000ff00ULL) << 40) | \
( ((uint64_t)(x) & 0x00000000000000ffULL) << 56))
/* auto-detect integer size */
/* auto-detect integer size */
#define BYTE_SWAP_INT(x) (sizeof(x)==2 ? BYTE_SWAP_16(x) : sizeof(x)==4 ? BYTE_SWAP_32(x) : (x))
#define BYTE_SWAP_INT(x) (sizeof(x)==2 ? BYTE_SWAP_16(x) : sizeof(x)==4 ? BYTE_SWAP_32(x) :
sizeof(x)==8 ? BYTE_SWAP_64(x) :
(x))
/********************************/
/********************************/
/* Architecture-specific macros */
/* Architecture-specific macros */
...
@@ -42,11 +50,13 @@
...
@@ -42,11 +50,13 @@
#define BE_LONG(x) (x)
#define BE_LONG(x) (x)
#define BE_INT16(x) (x)
#define BE_INT16(x) (x)
#define BE_INT32(x) (x)
#define BE_INT32(x) (x)
#define BE_INT64(x) (x)
#define BE_INT(x) (x)
#define BE_INT(x) (x)
#define LE_SHORT(x) BYTE_SWAP_16(x)
#define LE_SHORT(x) BYTE_SWAP_16(x)
#define LE_LONG(x) BYTE_SWAP_32(x)
#define LE_LONG(x) BYTE_SWAP_32(x)
#define LE_INT16(x) BYTE_SWAP_16(x)
#define LE_INT16(x) BYTE_SWAP_16(x)
#define LE_INT32(x) BYTE_SWAP_32(x)
#define LE_INT32(x) BYTE_SWAP_32(x)
#define LE_INT64(x) BYTE_SWAP_64(x)
#define LE_INT(x) BYTE_SWAP_INT(x)
#define LE_INT(x) BYTE_SWAP_INT(x)
#else
/* Little Endian (e.g. Intel) */
#else
/* Little Endian (e.g. Intel) */
...
@@ -55,11 +65,13 @@
...
@@ -55,11 +65,13 @@
#define LE_LONG(x) (x)
#define LE_LONG(x) (x)
#define LE_INT16(x) (x)
#define LE_INT16(x) (x)
#define LE_INT32(x) (x)
#define LE_INT32(x) (x)
#define LE_INT64(x) (x)
#define LE_INT(x) (x)
#define LE_INT(x) (x)
#define BE_SHORT(x) BYTE_SWAP_16(x)
#define BE_SHORT(x) BYTE_SWAP_16(x)
#define BE_LONG(x) BYTE_SWAP_32(x)
#define BE_LONG(x) BYTE_SWAP_32(x)
#define BE_INT16(x) BYTE_SWAP_16(x)
#define BE_INT16(x) BYTE_SWAP_16(x)
#define BE_INT32(x) BYTE_SWAP_32(x)
#define BE_INT32(x) BYTE_SWAP_32(x)
#define BE_INT64(x) BYTE_SWAP_64(x)
#define BE_INT(x) BYTE_SWAP_INT(x)
#define BE_INT(x) BYTE_SWAP_INT(x)
#endif
#endif
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment