mirror of
https://github.com/janet-lang/janet
synced 2024-12-26 00:10:27 +00:00
Replace cast with type pun.
This commit is contained in:
parent
69b6894f6b
commit
4c4eff9390
2
Makefile
2
Makefile
@ -152,6 +152,7 @@ valgrind: $(JANET_TARGET)
|
|||||||
valgrind --leak-check=full -v ./$(JANET_TARGET)
|
valgrind --leak-check=full -v ./$(JANET_TARGET)
|
||||||
|
|
||||||
test: $(JANET_TARGET) $(TEST_PROGRAMS)
|
test: $(JANET_TARGET) $(TEST_PROGRAMS)
|
||||||
|
ctest/system_test.out
|
||||||
ctest/array_test.out
|
ctest/array_test.out
|
||||||
ctest/buffer_test.out
|
ctest/buffer_test.out
|
||||||
./$(JANET_TARGET) test/suite0.janet
|
./$(JANET_TARGET) test/suite0.janet
|
||||||
@ -159,6 +160,7 @@ test: $(JANET_TARGET) $(TEST_PROGRAMS)
|
|||||||
./$(JANET_TARGET) test/suite2.janet
|
./$(JANET_TARGET) test/suite2.janet
|
||||||
|
|
||||||
valtest: $(JANET_TARGET) $(TEST_PROGRAMS)
|
valtest: $(JANET_TARGET) $(TEST_PROGRAMS)
|
||||||
|
valgrind --leak-check=full -b ctest/system_test.out
|
||||||
valgrind --leak-check=full -v ctest/array_test.out
|
valgrind --leak-check=full -v ctest/array_test.out
|
||||||
valgrind --leak-check=full -v ctest/buffer_test.out
|
valgrind --leak-check=full -v ctest/buffer_test.out
|
||||||
valgrind --leak-check=full -v ./$(JANET_TARGET) test/suite0.janet
|
valgrind --leak-check=full -v ./$(JANET_TARGET) test/suite0.janet
|
||||||
|
37
ctest/system_test.c
Normal file
37
ctest/system_test.c
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2018 Calvin Rose
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to
|
||||||
|
* deal in the Software without restriction, including without limitation the
|
||||||
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
* sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
* IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <janet/janet.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
|
||||||
|
#ifdef JANET_32
|
||||||
|
assert(sizeof(void *) == 4);
|
||||||
|
#else
|
||||||
|
assert(sizeof(void *) == 8);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@ -36,7 +36,8 @@ void *janet_nanbox_to_pointer(Janet x) {
|
|||||||
#else
|
#else
|
||||||
x.i64 = (x.i64 << 16) >> 16;
|
x.i64 = (x.i64 << 16) >> 16;
|
||||||
#endif
|
#endif
|
||||||
return (void *)x.i64;
|
|
||||||
|
return x.pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
Janet janet_nanbox_from_pointer(void *p, uint64_t tagmask) {
|
Janet janet_nanbox_from_pointer(void *p, uint64_t tagmask) {
|
||||||
|
@ -342,6 +342,7 @@ union Janet {
|
|||||||
uint64_t u64;
|
uint64_t u64;
|
||||||
int64_t i64;
|
int64_t i64;
|
||||||
double real;
|
double real;
|
||||||
|
void *pointer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define janet_u64(x) ((x).u64)
|
#define janet_u64(x) ((x).u64)
|
||||||
|
@ -35,7 +35,7 @@ int janet_line_getter(JanetArgs args) {
|
|||||||
|
|
||||||
static void simpleline(JanetBuffer *buffer) {
|
static void simpleline(JanetBuffer *buffer) {
|
||||||
buffer->count = 0;
|
buffer->count = 0;
|
||||||
char c;
|
int c;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
c = fgetc(stdin);
|
c = fgetc(stdin);
|
||||||
if (feof(stdin) || c < 0) {
|
if (feof(stdin) || c < 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user