Skip to content

Patch of wkechel and Windows Build #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,38 @@ License
-------

Copyright 2015-2023 Ruby Lane. Licensed under the same terms as the Tcl core.

Building under Windows msys2
-------

* Install msys2: `choco.exe install -y msys2`
* Start Terminal: `C:\tools\msys64\mingw64.exe`
* Install tools:
```bash
pacman --noconfirm -S --needed autoconf \
base-devel\
development\
cmake\
mingw-w64-x86_64-toolchain\
mingw-w64-cross-binutils\
gcc\
rsync\
unzip\
git\
vim
```
* Make sure tcl is installed
* git clone <repo>
* cd <repo>
* build:
```bash
INSTALLDIR="${INSTALLDIR:-build/x64}"
SHAREDIR=${INSTALLDIR}/share
VERSION="0.15.2"
BUILD_OPTS="${CONFIG:- --prefix=$(pwd)/${INSTALLDIR} --mandir=$(pwd)/${SHAREDIR}}"

autoconf
./configure ${BUILD_OPTS}
make -j8
make install
```
Empty file modified bench/old.tcl
100644 → 100755
Empty file.
1 change: 0 additions & 1 deletion bench/run.tcl

This file was deleted.

47 changes: 47 additions & 0 deletions bench/run.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# vim: ft=tcl foldmethod=marker foldmarker=<<<,>>> ts=4 shiftwidth=4

set big [string repeat a [expr {int(1e8)}]] ;# Allocate 100MB to pre-expand the zippy pool
unset big

set this_script [file normalize [info script]]
set seen {}
while {[file type $this_script] eq "link"} {
dict set seen $this_script 1
set this_script [file normalize [file join [file dirname $this_script] [file readlink $this_script]]]
if {[dict exists $seen $this_script]} {
error "Symlink loop detected while trying to resolve [file normalize [info script]]"
}
}
unset seen
set here [file dirname $this_script]
tcl::tm::path add $here

package require teabase_bench

proc main {} {
global here
try {
puts "[string repeat - 80]\nStarting benchmarks\n"
teabase_bench::run_benchmarks [file dirname [file normalize [info script]]] {*}$::argv
} on ok {} {
exit 0
} trap {BENCH BAD_RESULT} {errmsg options} {
puts stderr $errmsg
exit 1
} trap {BENCH BAD_CODE} {errmsg options} {
puts stderr $errmsg
exit 1
} trap {BENCH INVALID_ARG} {errmsg options} {
puts stderr $errmsg
exit 1
} trap exit code {
exit $code
} on error {errmsg options} {
puts stderr "Unhandled error from benchmark_mode: [dict get $options -errorinfo]"
exit 2
}
}

main

# vim: ft=tcl foldmethod=marker foldmarker=<<<,>>> ts=4 shiftwidth=4
3 changes: 3 additions & 0 deletions configure.ac
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ if test "${TEA_PLATFORM}" = "windows" ; then
:
#TEA_ADD_SOURCES([win/winFile.c])
#TEA_ADD_INCLUDES([-I\"$(${CYGPATH} ${srcdir}/win)\"])
dnl start PRS changes
TEA_ADD_LIBS([ws2_32.lib])
dnl end PRS changes
else
# Ensure no empty else clauses
:
Expand Down
61 changes: 42 additions & 19 deletions generic/cbor.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#include "rl_jsonInt.h"

/*
* Renamed enum values, see:
* https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/hresult-values
*/
enum svalue_types {
S_FALSE = 20,
S_TRUE = 21,
S_NULL = 22,
S_UNDEF = 23
CBOR_FALSE = 20,
CBOR_TRUE = 21,
CBOR_NULL = 22,
CBOR_UNDEF = 23
};

enum indexmode {
Expand Down Expand Up @@ -51,7 +55,7 @@ static float decode_float(const uint8_t* p) { //{{{
//}}}
static double decode_double(const uint8_t* p) { //{{{
double val;
uint64_t uval = be64toh(*(uint64_t*)p);
uint64_t uval = be64Itoh(*(uint64_t*)p);
memcpy(&val, &uval, sizeof(double));
return val;
}
Expand Down Expand Up @@ -109,7 +113,7 @@ static int well_formed(Tcl_Interp* interp, const uint8_t** pPtr, const uint8_t*
case 24: TEST_OK_LABEL(finally, code, take(interp, pPtr, e, 1, &part)); val = *(uint8_t*)part; break;
case 25: TEST_OK_LABEL(finally, code, take(interp, pPtr, e, 2, &part)); val = be16toh(*(uint16_t*)part); break;
case 26: TEST_OK_LABEL(finally, code, take(interp, pPtr, e, 4, &part)); val = be32toh(*(uint32_t*)part); break;
case 27: TEST_OK_LABEL(finally, code, take(interp, pPtr, e, 8, &part)); val = be64toh(*(uint64_t*)part); break;
case 27: TEST_OK_LABEL(finally, code, take(interp, pPtr, e, 8, &part)); val = be64Itoh(*(uint64_t*)part); break;
case 28: case 29: case 30: CBOR_INVALID(finally, code, "reserved additional info value: %d", ai);
case 31: return well_formed_indefinite(interp, pPtr, e, breakable, mtPtr, mt);
}
Expand Down Expand Up @@ -365,7 +369,7 @@ static int cbor_get_obj(Tcl_Interp* interp, const uint8_t** pPtr, const uint8_t*
case 24: TAKE(1); val = *(uint8_t*)valPtr; break;
case 25: TAKE(2); val = be16toh(*(uint16_t*)valPtr); break;
case 26: TAKE(4); val = be32toh(*(uint32_t*)valPtr); break;
case 27: TAKE(8); val = be64toh(*(uint64_t*)valPtr); break;
case 27: TAKE(8); val = be64Itoh(*(uint64_t*)valPtr); break;
case 28: case 29: case 30: CBOR_INVALID(finally, code, "reserved additional info value: %d", ai);
}

Expand Down Expand Up @@ -413,11 +417,17 @@ static int cbor_get_obj(Tcl_Interp* interp, const uint8_t** pPtr, const uint8_t*
uint64_t chunk_val;

switch (chunk_ai) {
case 0 ... 23: chunk_val = chunk_ai; break;
//case 0 ... 23:
case 0: case 1: case 2: case 3: case 4:
case 5: case 6: case 7: case 8: case 9:
case 10: case 11: case 12: case 13: case 14:
case 15: case 16: case 17: case 18: case 19:
case 20: case 21: case 22: case 23:
chunk_val = chunk_ai; break;
case 24: TAKE(1); chunk_val = *(uint8_t*)valPtr; break;
case 25: TAKE(2); chunk_val = be16toh(*(uint16_t*)valPtr); break;
case 26: TAKE(4); chunk_val = be32toh(*(uint32_t*)valPtr); break;
case 27: TAKE(8); chunk_val = be64toh(*(uint64_t*)valPtr); break;
case 27: TAKE(8); chunk_val = be64Itoh(*(uint64_t*)valPtr); break;
default: CBOR_INVALID(finally, code, "invalid chunk additional info: %d", chunk_ai);
}
TAKE(chunk_val);
Expand Down Expand Up @@ -479,16 +489,29 @@ static int cbor_get_obj(Tcl_Interp* interp, const uint8_t** pPtr, const uint8_t*
case M_REAL:
{
switch (ai) {
case 0 ... 19: replace_tclobj(&res, Tcl_ObjPrintf("simple(%" PRIu64 ")", val)); break;
case S_FALSE: replace_tclobj(&res, l->cbor_false); break;
case S_TRUE: replace_tclobj(&res, l->cbor_true); break;
case S_NULL: replace_tclobj(&res, l->cbor_null); break;
case S_UNDEF: replace_tclobj(&res, l->cbor_undefined); break;
//case 0 ... 19:
case 0: case 1: case 2: case 3: case 4:
case 5: case 6: case 7: case 8: case 9:
case 10: case 11: case 12: case 13: case 14:
case 15: case 16: case 17: case 18: case 19:
replace_tclobj(&res, Tcl_ObjPrintf("simple(%" PRIu64 ")", val)); break;
case CBOR_FALSE: replace_tclobj(&res, l->cbor_false); break;
case CBOR_TRUE: replace_tclobj(&res, l->cbor_true); break;
case CBOR_NULL: replace_tclobj(&res, l->cbor_null); break;
case CBOR_UNDEF: replace_tclobj(&res, l->cbor_undefined); break;
case 24:
#if 1
if (val >= 32 && val <= 255) {
replace_tclobj(&res, Tcl_ObjPrintf("simple(%" PRIu64 ")", val));
} else {
CBOR_INVALID(finally, code, "invalid simple value: %" PRIu64, val);
}
#else
switch (val) {
case 32 ... 255: replace_tclobj(&res, Tcl_ObjPrintf("simple(%" PRIu64 ")", val)); break;
default: CBOR_INVALID(finally, code, "invalid simple value: %" PRIu64, val);
default: CBOR_INVALID(finally, code, "invalid simple value: %" PRIu64, val);
}
#endif
break;
case 25: replace_tclobj(&res, Tcl_NewDoubleObj( decode_half(valPtr) )); break;
case 26: replace_tclobj(&res, Tcl_NewDoubleObj( decode_float(valPtr) )); break;
Expand Down Expand Up @@ -674,7 +697,7 @@ static int cbor_matches(Tcl_Interp* interp, const uint8_t** pPtr, const uint8_t*
case 24: TAKE(1); val = *(uint8_t*)valPtr; break;
case 25: TAKE(2); val = be16toh(*(uint16_t*)valPtr); break;
case 26: TAKE(4); val = be32toh(*(uint32_t*)valPtr); break;
case 27: TAKE(8); val = be64toh(*(uint64_t*)valPtr); break;
case 27: TAKE(8); val = be64Itoh(*(uint64_t*)valPtr); break;
case 28: case 29: case 30: CBOR_INVALID(finally, code, "reserved additional info value: %d", ai);
}
//}}}
Expand Down Expand Up @@ -730,7 +753,7 @@ static int cbor_matches(Tcl_Interp* interp, const uint8_t** pPtr, const uint8_t*
case 24: TAKE(1); chunk_val = *(uint8_t*)valPtr; break;
case 25: TAKE(2); chunk_val = be16toh(*(uint16_t*)valPtr); break;
case 26: TAKE(4); chunk_val = be32toh(*(uint32_t*)valPtr); break;
case 27: TAKE(8); chunk_val = be64toh(*(uint64_t*)valPtr); break;
case 27: TAKE(8); chunk_val = be64Itoh(*(uint64_t*)valPtr); break;
case 28: case 29: case 30: CBOR_INVALID(finally, code, "reserved additional info value: %d", chunk_ai);
case 31: CBOR_INVALID(finally, code, "cannot nest indefinite length chunks");
}
Expand Down Expand Up @@ -789,7 +812,7 @@ static int cbor_matches(Tcl_Interp* interp, const uint8_t** pPtr, const uint8_t*
case 24: TAKE(1); chunk_val = *(uint8_t*)valPtr; break;
case 25: TAKE(2); chunk_val = be16toh(*(uint16_t*)valPtr); break;
case 26: TAKE(4); chunk_val = be32toh(*(uint32_t*)valPtr); break;
case 27: TAKE(8); chunk_val = be64toh(*(uint64_t*)valPtr); break;
case 27: TAKE(8); chunk_val = be64Itoh(*(uint64_t*)valPtr); break;
case 28: case 29: case 30: CBOR_INVALID(finally, code, "reserved additional info value: %d", chunk_ai);
case 31: CBOR_INVALID(finally, code, "cannot nest indefinite length chunks");
}
Expand Down Expand Up @@ -1005,7 +1028,7 @@ int CBOR_GetDataItemFromPath(Tcl_Interp* interp, Tcl_Obj* cborObj, Tcl_Obj* path
case 24: TAKE(1); val = *(uint8_t*)valPtr; break;
case 25: TAKE(2); val = be16toh(*(uint16_t*)valPtr); break;
case 26: TAKE(4); val = be32toh(*(uint32_t*)valPtr); break;
case 27: TAKE(8); val = be64toh(*(uint64_t*)valPtr); break;
case 27: TAKE(8); val = be64Itoh(*(uint64_t*)valPtr); break;
case 28: case 29: case 30: CBOR_INVALID(finally, code, "reserved additional info value: %d", ai);
}

Expand Down
1 change: 0 additions & 1 deletion generic/names.c

This file was deleted.

Loading