on master help sign in
C style changes while porting rts to 9front (#3596)
36aaf7fjoe9
rts/idris_bitstring.c+8−8
@@ -823,37 +823,37 @@ VAL idris_b64T32(VM *vm, VAL a) {
823}
823}
824
824
825VAL idris_peekB8(VM* vm, VAL ptr, VAL offset) {
825VAL idris_peekB8(VM* vm, VAL ptr, VAL offset) {
826− return MKB8(vm, *(uint8_t*)(GETPTR(ptr) + GETINT(offset)));
826+ return MKB8(vm, *(uint8_t*)((char *)GETPTR(ptr) + GETINT(offset)));
827}
827}
828
828
829VAL idris_pokeB8(VAL ptr, VAL offset, VAL data) {
829VAL idris_pokeB8(VAL ptr, VAL offset, VAL data) {
830− *(uint8_t*)(GETPTR(ptr) + GETINT(offset)) = GETBITS8(data);
830+ *(uint8_t*)((char *)GETPTR(ptr) + GETINT(offset)) = GETBITS8(data);
831 return MKINT(0);
831 return MKINT(0);
832}
832}
833
833
834VAL idris_peekB16(VM* vm, VAL ptr, VAL offset) {
834VAL idris_peekB16(VM* vm, VAL ptr, VAL offset) {
835− return MKB16(vm, *(uint16_t*)(GETPTR(ptr) + GETINT(offset)));
835+ return MKB16(vm, *(uint16_t*)((char *)GETPTR(ptr) + GETINT(offset)));
836}
836}
837
837
838VAL idris_pokeB16(VAL ptr, VAL offset, VAL data) {
838VAL idris_pokeB16(VAL ptr, VAL offset, VAL data) {
839− *(uint16_t*)(GETPTR(ptr) + GETINT(offset)) = GETBITS16(data);
839+ *(uint16_t*)((char *)GETPTR(ptr) + GETINT(offset)) = GETBITS16(data);
840 return MKINT(0);
840 return MKINT(0);
841}
841}
842
842
843VAL idris_peekB32(VM* vm, VAL ptr, VAL offset) {
843VAL idris_peekB32(VM* vm, VAL ptr, VAL offset) {
844− return MKB32(vm, *(uint32_t*)(GETPTR(ptr) + GETINT(offset)));
844+ return MKB32(vm, *(uint32_t*)((char *)GETPTR(ptr) + GETINT(offset)));
845}
845}
846
846
847VAL idris_pokeB32(VAL ptr, VAL offset, VAL data) {
847VAL idris_pokeB32(VAL ptr, VAL offset, VAL data) {
848− *(uint32_t*)(GETPTR(ptr) + GETINT(offset)) = GETBITS32(data);
848+ *(uint32_t*)((char *)GETPTR(ptr) + GETINT(offset)) = GETBITS32(data);
849 return MKINT(0);
849 return MKINT(0);
850}
850}
851
851
852VAL idris_peekB64(VM* vm, VAL ptr, VAL offset) {
852VAL idris_peekB64(VM* vm, VAL ptr, VAL offset) {
853− return MKB64(vm, *(uint64_t*)(GETPTR(ptr) + GETINT(offset)));
853+ return MKB64(vm, *(uint64_t*)((char *)GETPTR(ptr) + GETINT(offset)));
854}
854}
855
855
856VAL idris_pokeB64(VAL ptr, VAL offset, VAL data) {
856VAL idris_pokeB64(VAL ptr, VAL offset, VAL data) {
857− *(uint64_t*)(GETPTR(ptr) + GETINT(offset)) = GETBITS64(data);
857+ *(uint64_t*)((char *)GETPTR(ptr) + GETINT(offset)) = GETBITS64(data);
858 return MKINT(0);
858 return MKINT(0);
859}
859}
rts/idris_gmp.c+1−1
@@ -14,7 +14,7 @@
14// much space is needed (or find another way of preventing copying)
14// much space is needed (or find another way of preventing copying)
15#define IDRIS_MAXGMP 65536
15#define IDRIS_MAXGMP 65536
16
16
17−void init_gmpalloc() {
17+void init_gmpalloc(void) {
18 mp_set_memory_functions(idris_alloc, idris_realloc, idris_free);
18 mp_set_memory_functions(idris_alloc, idris_realloc, idris_free);
19}
19}
20
20
rts/idris_gmp.h+1−1
@@ -8,7 +8,7 @@
8#endif
8#endif
9
9
10// Set memory allocation functions
10// Set memory allocation functions
11−void init_gmpalloc();
11+void init_gmpalloc(void);
12
12
13VAL MKBIGI(int val);
13VAL MKBIGI(int val);
14VAL MKBIGC(VM* vm, char* bigint);
14VAL MKBIGC(VM* vm, char* bigint);
rts/idris_rts.c+19−19
@@ -70,7 +70,7 @@ VM* init_vm(int stack_size, size_t heap_size,
70 return vm;
70 return vm;
71}
71}
72
72
73−VM* idris_vm() {
73+VM* idris_vm(void) {
74 VM* vm = init_vm(4096000, 4096000, 1);
74 VM* vm = init_vm(4096000, 4096000, 1);
75 init_threadkeys();
75 init_threadkeys();
76 init_threaddata(vm);
76 init_threaddata(vm);
@@ -95,12 +95,12 @@ void close_vm(VM* vm) {
95}
95}
96
96
97#ifdef HAS_PTHREAD
97#ifdef HAS_PTHREAD
98−void create_key() {
98+void create_key(void) {
99 pthread_key_create(&vm_key, (void*)free_key);
99 pthread_key_create(&vm_key, (void*)free_key);
100}
100}
101#endif
101#endif
102
102
103−void init_threadkeys() {
103+void init_threadkeys(void) {
104#ifdef HAS_PTHREAD
104#ifdef HAS_PTHREAD
105 static pthread_once_t key_once = PTHREAD_ONCE_INIT;
105 static pthread_once_t key_once = PTHREAD_ONCE_INIT;
106 pthread_once(&key_once, create_key);
106 pthread_once(&key_once, create_key);
@@ -113,7 +113,7 @@ void init_threaddata(VM *vm) {
113#endif
113#endif
114}
114}
115
115
116−void init_signals() {
116+void init_signals(void) {
117#if (__linux__ || __APPLE__ || __FreeBSD__ || __DragonFly__)
117#if (__linux__ || __APPLE__ || __FreeBSD__ || __DragonFly__)
118 signal(SIGPIPE, SIG_IGN);
118 signal(SIGPIPE, SIG_IGN);
119#endif
119#endif
@@ -173,7 +173,7 @@ void idris_requireAlloc(size_t size) {
173#endif
173#endif
174}
174}
175
175
176−void idris_doneAlloc() {
176+void idris_doneAlloc(void) {
177#ifdef HAS_PTHREAD
177#ifdef HAS_PTHREAD
178 VM* vm = pthread_getspecific(vm_key);
178 VM* vm = pthread_getspecific(vm_key);
179 int lock = vm->processes > 0;
179 int lock = vm->processes > 0;
@@ -191,7 +191,7 @@ void* idris_alloc(size_t size) {
191 Closure* cl = (Closure*) allocate(sizeof(Closure)+size, 0);
191 Closure* cl = (Closure*) allocate(sizeof(Closure)+size, 0);
192 SETTY(cl, CT_RAWDATA);
192 SETTY(cl, CT_RAWDATA);
193 cl->info.size = size;
193 cl->info.size = size;
194− return (void*)cl+sizeof(Closure);
194+ return (void*)((char *)cl+sizeof(Closure));
195}
195}
196
196
197void* idris_realloc(void* old, size_t old_size, size_t size) {
197void* idris_realloc(void* old, size_t old_size, size_t size) {
@@ -449,36 +449,36 @@ void idris_poke(void* ptr, i_int offset, uint8_t data) {
449
449
450
450
451VAL idris_peekPtr(VM* vm, VAL ptr, VAL offset) {
451VAL idris_peekPtr(VM* vm, VAL ptr, VAL offset) {
452− void** addr = GETPTR(ptr) + GETINT(offset);
452+ void** addr = (void **)((char *)GETPTR(ptr) + GETINT(offset));
453 return MKPTR(vm, *addr);
453 return MKPTR(vm, *addr);
454}
454}
455
455
456VAL idris_pokePtr(VAL ptr, VAL offset, VAL data) {
456VAL idris_pokePtr(VAL ptr, VAL offset, VAL data) {
457− void** addr = GETPTR(ptr) + GETINT(offset);
457+ void** addr = (void **)((char *)GETPTR(ptr) + GETINT(offset));
458 *addr = GETPTR(data);
458 *addr = GETPTR(data);
459 return MKINT(0);
459 return MKINT(0);
460}
460}
461
461
462VAL idris_peekDouble(VM* vm, VAL ptr, VAL offset) {
462VAL idris_peekDouble(VM* vm, VAL ptr, VAL offset) {
463− return MKFLOAT(vm, *(double*)(GETPTR(ptr) + GETINT(offset)));
463+ return MKFLOAT(vm, *(double*)((char *)GETPTR(ptr) + GETINT(offset)));
464}
464}
465
465
466VAL idris_pokeDouble(VAL ptr, VAL offset, VAL data) {
466VAL idris_pokeDouble(VAL ptr, VAL offset, VAL data) {
467− *(double*)(GETPTR(ptr) + GETINT(offset)) = GETFLOAT(data);
467+ *(double*)((char *)GETPTR(ptr) + GETINT(offset)) = GETFLOAT(data);
468 return MKINT(0);
468 return MKINT(0);
469}
469}
470
470
471VAL idris_peekSingle(VM* vm, VAL ptr, VAL offset) {
471VAL idris_peekSingle(VM* vm, VAL ptr, VAL offset) {
472− return MKFLOAT(vm, *(float*)(GETPTR(ptr) + GETINT(offset)));
472+ return MKFLOAT(vm, *(float*)((char *)GETPTR(ptr) + GETINT(offset)));
473}
473}
474
474
475VAL idris_pokeSingle(VAL ptr, VAL offset, VAL data) {
475VAL idris_pokeSingle(VAL ptr, VAL offset, VAL data) {
476− *(float*)(GETPTR(ptr) + GETINT(offset)) = GETFLOAT(data);
476+ *(float*)((char *)GETPTR(ptr) + GETINT(offset)) = GETFLOAT(data);
477 return MKINT(0);
477 return MKINT(0);
478}
478}
479
479
480void idris_memmove(void* dest, void* src, i_int dest_offset, i_int src_offset, i_int size) {
480void idris_memmove(void* dest, void* src, i_int dest_offset, i_int src_offset, i_int size) {
481− memmove(dest + dest_offset, src + src_offset, size);
481+ memmove((char *)dest + dest_offset, (char *)src + src_offset, size);
482}
482}
483
483
484VAL idris_castIntStr(VM* vm, VAL i) {
484VAL idris_castIntStr(VM* vm, VAL i) {
@@ -1046,7 +1046,7 @@ void idris_freeMsg(Msg* msg) {
1046 free(msg);
1046 free(msg);
1047}
1047}
1048
1048
1049−int idris_errno() {
1049+int idris_errno(void) {
1050 return errno;
1050 return errno;
1051}
1051}
1052
1052
@@ -1056,7 +1056,7 @@ char* idris_showerror(int err) {
1056
1056
1057VAL* nullary_cons;
1057VAL* nullary_cons;
1058
1058
1059−void init_nullaries() {
1059+void init_nullaries(void) {
1060 int i;
1060 int i;
1061 VAL cl;
1061 VAL cl;
1062 nullary_cons = malloc(256 * sizeof(VAL));
1062 nullary_cons = malloc(256 * sizeof(VAL));
@@ -1068,7 +1068,7 @@ void init_nullaries() {
1068 }
1068 }
1069}
1069}
1070
1070
1071−void free_nullaries() {
1071+void free_nullaries(void) {
1072 int i;
1072 int i;
1073 for(i = 0; i < 256; ++i) {
1073 for(i = 0; i < 256; ++i) {
1074 free(nullary_cons[i]);
1074 free(nullary_cons[i]);
@@ -1079,7 +1079,7 @@ void free_nullaries() {
1079int __idris_argc;
1079int __idris_argc;
1080char **__idris_argv;
1080char **__idris_argv;
1081
1081
1082−int idris_numArgs() {
1082+int idris_numArgs(void) {
1083 return __idris_argc;
1083 return __idris_argc;
1084}
1084}
1085
1085
@@ -1087,12 +1087,12 @@ const char* idris_getArg(int i) {
1087 return __idris_argv[i];
1087 return __idris_argv[i];
1088}
1088}
1089
1089
1090−void idris_disableBuffering() {
1090+void idris_disableBuffering(void) {
1091 setvbuf(stdin, NULL, _IONBF, 0);
1091 setvbuf(stdin, NULL, _IONBF, 0);
1092 setvbuf(stdout, NULL, _IONBF, 0);
1092 setvbuf(stdout, NULL, _IONBF, 0);
1093}
1093}
1094
1094
1095−void stackOverflow() {
1095+void stackOverflow(void) {
1096 fprintf(stderr, "Stack overflow");
1096 fprintf(stderr, "Stack overflow");
1097 exit(-1);
1097 exit(-1);
1098}
1098}
rts/idris_rts.h+10−10
@@ -161,11 +161,11 @@ Stats terminate(VM* vm);
161
161
162// Create a new VM, set up everything with sensible defaults (use when
162// Create a new VM, set up everything with sensible defaults (use when
163// calling Idris from C)
163// calling Idris from C)
164−VM* idris_vm();
164+VM* idris_vm(void);
165void close_vm(VM* vm);
165void close_vm(VM* vm);
166
166
167// Set up key for thread-local data - called once from idris_main
167// Set up key for thread-local data - called once from idris_main
168−void init_threadkeys();
168+void init_threadkeys(void);
169
169
170// Functions all take a pointer to their VM, and previous stack base,
170// Functions all take a pointer to their VM, and previous stack base,
171// and return nothing.
171// and return nothing.
@@ -278,7 +278,7 @@ void* allocate(size_t size, int outerlock);
278// may take a lock if other threads are running).
278// may take a lock if other threads are running).
279
279
280void idris_requireAlloc(size_t size);
280void idris_requireAlloc(size_t size);
281−void idris_doneAlloc();
281+void idris_doneAlloc(void);
282
282
283// public interface to allocation (note that this may move other pointers
283// public interface to allocation (note that this may move other pointers
284// if allocating beyond the limits given by idris_requireAlloc!)
284// if allocating beyond the limits given by idris_requireAlloc!)
@@ -299,14 +299,14 @@ void idris_free(void* ptr, size_t size);
299
299
300#define NULL_CON(x) nullary_cons[x]
300#define NULL_CON(x) nullary_cons[x]
301
301
302−int idris_errno();
302+int idris_errno(void);
303char* idris_showerror(int err);
303char* idris_showerror(int err);
304
304
305extern VAL* nullary_cons;
305extern VAL* nullary_cons;
306−void init_nullaries();
306+void init_nullaries(void);
307−void free_nullaries();
307+void free_nullaries(void);
308
308
309−void init_signals();
309+void init_signals(void);
310
310
311void* vmThread(VM* callvm, func f, VAL arg);
311void* vmThread(VM* callvm, func f, VAL arg);
312void* idris_stopThread(VM* vm);
312void* idris_stopThread(VM* vm);
@@ -394,16 +394,16 @@ VAL idris_systemInfo(VM* vm, VAL index);
394extern int __idris_argc;
394extern int __idris_argc;
395extern char **__idris_argv;
395extern char **__idris_argv;
396
396
397−int idris_numArgs();
397+int idris_numArgs(void);
398const char *idris_getArg(int i);
398const char *idris_getArg(int i);
399
399
400// disable stdin/stdout buffering
400// disable stdin/stdout buffering
401−void idris_disableBuffering();
401+void idris_disableBuffering(void);
402
402
403// Handle stack overflow.
403// Handle stack overflow.
404// Just reports an error and exits.
404// Just reports an error and exits.
405
405
406−void stackOverflow();
406+void stackOverflow(void);
407
407
408// I think these names are nicer for an API...
408// I think these names are nicer for an API...
409
409
src/IRTS/CodegenC.hs+1−1
@@ -674,7 +674,7 @@ doOp v (LExternal pk) [] | pk == sUN "prim__sizeofPtr"
674doOp v (LExternal mpt) [p] | mpt == sUN "prim__asPtr"
674doOp v (LExternal mpt) [p] | mpt == sUN "prim__asPtr"
675 = v ++ "MKPTR(vm, GETMPTR("++ creg p ++"))"
675 = v ++ "MKPTR(vm, GETMPTR("++ creg p ++"))"
676doOp v (LExternal offs) [p, n] | offs == sUN "prim__ptrOffset"
676doOp v (LExternal offs) [p, n] | offs == sUN "prim__ptrOffset"
677− = v ++ "MKPTR(vm, GETPTR(" ++ creg p ++ ") + GETINT(" ++ creg n ++ "))"
677+ = v ++ "MKPTR(vm, (void *)((char *)GETPTR(" ++ creg p ++ ") + GETINT(" ++ creg n ++ ")))"
678doOp _ op args = error $ "doOp not implemented (" ++ show (op, args) ++ ")"
678doOp _ op args = error $ "doOp not implemented (" ++ show (op, args) ++ ")"
679
679
680
680