diff options
author | Damien George <damien.p.george@gmail.com> | 2014-05-21 19:51:05 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-05-21 19:51:05 +0100 |
commit | 0fd01683c61e039461854b49d1baf8a72aa277fb (patch) | |
tree | d640987a46c93272b1deb229cd942a411ad06d92 /unix | |
parent | 6ac5dced2441bf63dbc65acbd7e33fb71d1d3ede (diff) | |
parent | da1fffaa093d2541f7374a7aaf16d2f00ed29ddc (diff) |
Merge pull request #607 from Anton-2/osx-clang
Allow compilation of unix port under clang on OS X
Diffstat (limited to 'unix')
-rw-r--r-- | unix/Makefile | 9 | ||||
-rw-r--r-- | unix/gccollect.c | 6 | ||||
-rw-r--r-- | unix/modsocket.c | 4 | ||||
-rw-r--r-- | unix/order.def | 1 | ||||
-rw-r--r-- | unix/seg_helpers.c | 38 |
5 files changed, 54 insertions, 4 deletions
diff --git a/unix/Makefile b/unix/Makefile index b0b037cd7..b336892a4 100644 --- a/unix/Makefile +++ b/unix/Makefile @@ -19,8 +19,8 @@ CFLAGS = $(INC) -Wall -Werror -ansi -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Darwin) - LDFLAGS = $(LDFLAGS_MOD) -lm -Wl,-map,$@.map -else + LDFLAGS = $(LDFLAGS_MOD) -lm -Wl,-map,$@.map,-order_file,order.def + else LDFLAGS = $(LDFLAGS_MOD) -lm -Wl,-Map=$@.map,--cref endif @@ -71,6 +71,11 @@ SRC_C = \ modos.c \ $(SRC_MOD) +# Must be the last file +ifeq ($(UNAME_S),Darwin) +SRC_C += seg_helpers.c +endif + OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) include ../py/mkrules.mk diff --git a/unix/gccollect.c b/unix/gccollect.c index 647a1214d..1b5a38ffc 100644 --- a/unix/gccollect.c +++ b/unix/gccollect.c @@ -43,11 +43,17 @@ typedef machine_uint_t regs_t[6]; void gc_helper_get_regs(regs_t arr) { register long rbx asm ("rbx"); + asm("" : "=r"(rbx)); register long rbp asm ("rbp"); + asm("" : "=r"(rbp)); register long r12 asm ("r12"); + asm("" : "=r"(r12)); register long r13 asm ("r13"); + asm("" : "=r"(r13)); register long r14 asm ("r14"); + asm("" : "=r"(r14)); register long r15 asm ("r15"); + asm("" : "=r"(r15)); arr[0] = rbx; arr[1] = rbp; arr[2] = r12; diff --git a/unix/modsocket.c b/unix/modsocket.c index 08d0d56b6..5192c0243 100644 --- a/unix/modsocket.c +++ b/unix/modsocket.c @@ -292,6 +292,7 @@ STATIC const mp_obj_type_t microsocket_type = { .locals_dict = (mp_obj_t)µsocket_locals_dict, }; +#if MICROPY_SOCKET_EXTRA STATIC mp_obj_t mod_socket_htons(mp_obj_t arg) { return MP_OBJ_NEW_SMALL_INT((machine_int_t)htons(MP_OBJ_SMALL_INT_VALUE(arg))); } @@ -309,7 +310,6 @@ STATIC mp_obj_t mod_socket_inet_aton(mp_obj_t arg) { } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_socket_inet_aton_obj, mod_socket_inet_aton); -#if MICROPY_SOCKET_EXTRA STATIC mp_obj_t mod_socket_gethostbyname(mp_obj_t arg) { assert(MP_OBJ_IS_TYPE(arg, &mp_type_str)); const char *s = mp_obj_str_get_str(arg); @@ -322,7 +322,7 @@ STATIC mp_obj_t mod_socket_gethostbyname(mp_obj_t arg) { return mp_obj_new_int(*(int*)*h->h_addr_list); } STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_socket_gethostbyname_obj, mod_socket_gethostbyname); -#endif +#endif // MICROPY_SOCKET_EXTRA STATIC mp_obj_t mod_socket_getaddrinfo(uint n_args, const mp_obj_t *args) { // TODO: Implement all args diff --git a/unix/order.def b/unix/order.def new file mode 100644 index 000000000..34a4fea3e --- /dev/null +++ b/unix/order.def @@ -0,0 +1 @@ +seg_helpers.o: ___bss_start diff --git a/unix/seg_helpers.c b/unix/seg_helpers.c new file mode 100644 index 000000000..1684f7a8f --- /dev/null +++ b/unix/seg_helpers.c @@ -0,0 +1,38 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2013, 2014 Damien P. George + * + * 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. + */ + +/* + This is a stub used to create the symbols __bss_start and _end in a Mach-O object file. + Thoses are needed by the GC, and should point to the start and end of the bss section. + We reach this goal by linking this file last (putting _end at the end...), and using an + order file (order.def) to move __bss_start at the start of bss. + + TODO: Some pragma to do it inline ? +*/ + +char __bss_start = 0; +char _end = 0; + |