summaryrefslogtreecommitdiffstatshomepage
path: root/unix
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-07-03 13:25:24 +0100
committerDamien George <damien.p.george@gmail.com>2014-07-03 13:25:24 +0100
commit40f3c026823f8951a2fa04e9c7fc93c75bc27bec (patch)
treec9c8210654c7114f00c5234a8481d9b5fbd28ce0 /unix
parent065aba587571150074ea79483ffa72c0fe6bc8c8 (diff)
downloadmicropython-40f3c026823f8951a2fa04e9c7fc93c75bc27bec.tar.gz
micropython-40f3c026823f8951a2fa04e9c7fc93c75bc27bec.zip
Rename machine_(u)int_t to mp_(u)int_t.
See discussion in issue #50.
Diffstat (limited to 'unix')
-rw-r--r--unix/file.c12
-rw-r--r--unix/gccollect.c10
-rw-r--r--unix/main.c2
-rw-r--r--unix/modffi.c6
-rw-r--r--unix/modos.c14
-rw-r--r--unix/modsocket.c26
-rw-r--r--unix/modtime.c4
-rw-r--r--unix/mpconfigport.h10
8 files changed, 42 insertions, 42 deletions
diff --git a/unix/file.c b/unix/file.c
index 386f018bdd..62e3253b7d 100644
--- a/unix/file.c
+++ b/unix/file.c
@@ -62,20 +62,20 @@ STATIC void fdfile_print(void (*print)(void *env, const char *fmt, ...), void *e
print(env, "<io.%s %d>", mp_obj_get_type_str(self), self->fd);
}
-STATIC machine_int_t fdfile_read(mp_obj_t o_in, void *buf, machine_uint_t size, int *errcode) {
+STATIC mp_int_t fdfile_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) {
mp_obj_fdfile_t *o = o_in;
check_fd_is_open(o);
- machine_int_t r = read(o->fd, buf, size);
+ mp_int_t r = read(o->fd, buf, size);
if (r == -1) {
*errcode = errno;
}
return r;
}
-STATIC machine_int_t fdfile_write(mp_obj_t o_in, const void *buf, machine_uint_t size, int *errcode) {
+STATIC mp_int_t fdfile_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) {
mp_obj_fdfile_t *o = o_in;
check_fd_is_open(o);
- machine_int_t r = write(o->fd, buf, size);
+ mp_int_t r = write(o->fd, buf, size);
if (r == -1) {
*errcode = errno;
}
@@ -100,7 +100,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(fdfile___exit___obj, 4, 4, fdfile___e
STATIC mp_obj_t fdfile_fileno(mp_obj_t self_in) {
mp_obj_fdfile_t *self = self_in;
check_fd_is_open(self);
- return MP_OBJ_NEW_SMALL_INT((machine_int_t)self->fd);
+ return MP_OBJ_NEW_SMALL_INT((mp_int_t)self->fd);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(fdfile_fileno_obj, fdfile_fileno);
@@ -153,7 +153,7 @@ STATIC mp_obj_t fdfile_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const
const char *fname = mp_obj_str_get_str(args[0]);
int fd = open(fname, mode, 0644);
if (fd == -1) {
- nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((machine_int_t)errno)));
+ nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((mp_int_t)errno)));
}
o->fd = fd;
return o;
diff --git a/unix/gccollect.c b/unix/gccollect.c
index d04e5d87fb..32b3d8bc61 100644
--- a/unix/gccollect.c
+++ b/unix/gccollect.c
@@ -50,7 +50,7 @@ void gc_helper_get_regs(regs_t arr) {
// to capture caller-saved registers, because they, well, put on the
// stack already by the caller.
#ifdef __x86_64__
-typedef machine_uint_t regs_t[6];
+typedef mp_uint_t regs_t[6];
void gc_helper_get_regs(regs_t arr) {
register long rbx asm ("rbx");
@@ -83,7 +83,7 @@ void gc_helper_get_regs(regs_t arr) {
#endif
#ifdef __i386__
-typedef machine_uint_t regs_t[4];
+typedef mp_uint_t regs_t[4];
void gc_helper_get_regs(regs_t arr) {
register long ebx asm ("ebx");
@@ -98,7 +98,7 @@ void gc_helper_get_regs(regs_t arr) {
#endif
#if defined(__thumb2__) || defined(__thumb__) || defined(__arm__)
-typedef machine_uint_t regs_t[10];
+typedef mp_uint_t regs_t[10];
void gc_helper_get_regs(regs_t arr) {
register long r4 asm ("r4");
@@ -140,12 +140,12 @@ void gc_collect(void) {
#endif
extern char BSS_START, _end;
//printf(".bss: %p-%p\n", &BSS_START, &_end);
- gc_collect_root((void**)&BSS_START, ((machine_uint_t)&_end - (machine_uint_t)&BSS_START) / sizeof(machine_uint_t));
+ gc_collect_root((void**)&BSS_START, ((mp_uint_t)&_end - (mp_uint_t)&BSS_START) / sizeof(mp_uint_t));
regs_t regs;
gc_helper_get_regs(regs);
// GC stack (and regs because we captured them)
void **regs_ptr = (void**)(void*)&regs;
- gc_collect_root(regs_ptr, ((machine_uint_t)stack_top - (machine_uint_t)&regs) / sizeof(machine_uint_t));
+ gc_collect_root(regs_ptr, ((mp_uint_t)stack_top - (mp_uint_t)&regs) / sizeof(mp_uint_t));
gc_collect_end();
//printf("-----\n");
diff --git a/unix/main.c b/unix/main.c
index 176cbc6ec3..d0222de0d1 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -61,7 +61,7 @@ uint mp_verbose_flag;
#if MICROPY_ENABLE_GC
// Heap size of GC heap (if enabled)
// Make it larger on a 64 bit machine, because pointers are larger.
-long heap_size = 128*1024 * (sizeof(machine_uint_t) / 4);
+long heap_size = 128*1024 * (sizeof(mp_uint_t) / 4);
#endif
void microsocket_init();
diff --git a/unix/modffi.c b/unix/modffi.c
index eca3f9131b..796dec4199 100644
--- a/unix/modffi.c
+++ b/unix/modffi.c
@@ -179,7 +179,7 @@ STATIC mp_obj_t ffimod_func(uint n_args, const mp_obj_t *args) {
void *sym = dlsym(self->handle, symname);
if (sym == NULL) {
- nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((machine_int_t)errno)));
+ nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((mp_int_t)errno)));
}
int nparams = MP_OBJ_SMALL_INT_VALUE(mp_obj_len_maybe(args[3]));
mp_obj_ffifunc_t *o = m_new_obj_var(mp_obj_ffifunc_t, ffi_type*, nparams);
@@ -253,7 +253,7 @@ STATIC mp_obj_t ffimod_var(mp_obj_t self_in, mp_obj_t vartype_in, mp_obj_t symna
void *sym = dlsym(self->handle, symname);
if (sym == NULL) {
- nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((machine_int_t)errno)));
+ nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((mp_int_t)errno)));
}
mp_obj_ffivar_t *o = m_new_obj(mp_obj_ffivar_t);
o->base.type = &ffivar_type;
@@ -269,7 +269,7 @@ STATIC mp_obj_t ffimod_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const
void *mod = dlopen(fname, RTLD_NOW | RTLD_LOCAL);
if (mod == NULL) {
- nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((machine_int_t)errno)));
+ nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((mp_int_t)errno)));
}
mp_obj_ffimod_t *o = m_new_obj(mp_obj_ffimod_t);
o->base.type = type_in;
diff --git a/unix/modos.c b/unix/modos.c
index 9b034cdbc2..7ff3fbbb89 100644
--- a/unix/modos.c
+++ b/unix/modos.c
@@ -40,7 +40,7 @@
#define RAISE_ERRNO(err_flag, error_val) \
{ if (err_flag == -1) \
- { nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((machine_int_t)error_val))); } }
+ { nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((mp_int_t)error_val))); } }
STATIC mp_obj_t mod_os_stat(mp_obj_t path_in) {
struct stat sb;
@@ -51,12 +51,12 @@ STATIC mp_obj_t mod_os_stat(mp_obj_t path_in) {
RAISE_ERRNO(res, errno);
mp_obj_tuple_t *t = mp_obj_new_tuple(10, NULL);
- t->items[0] = MP_OBJ_NEW_SMALL_INT((machine_int_t)sb.st_mode);
- t->items[1] = MP_OBJ_NEW_SMALL_INT((machine_int_t)sb.st_ino);
- t->items[2] = MP_OBJ_NEW_SMALL_INT((machine_int_t)sb.st_dev);
- t->items[3] = MP_OBJ_NEW_SMALL_INT((machine_int_t)sb.st_nlink);
- t->items[4] = MP_OBJ_NEW_SMALL_INT((machine_int_t)sb.st_uid);
- t->items[5] = MP_OBJ_NEW_SMALL_INT((machine_int_t)sb.st_gid);
+ t->items[0] = MP_OBJ_NEW_SMALL_INT((mp_int_t)sb.st_mode);
+ t->items[1] = MP_OBJ_NEW_SMALL_INT((mp_int_t)sb.st_ino);
+ t->items[2] = MP_OBJ_NEW_SMALL_INT((mp_int_t)sb.st_dev);
+ t->items[3] = MP_OBJ_NEW_SMALL_INT((mp_int_t)sb.st_nlink);
+ t->items[4] = MP_OBJ_NEW_SMALL_INT((mp_int_t)sb.st_uid);
+ t->items[5] = MP_OBJ_NEW_SMALL_INT((mp_int_t)sb.st_gid);
t->items[6] = MP_OBJ_NEW_SMALL_INT(sb.st_size);
t->items[7] = MP_OBJ_NEW_SMALL_INT(sb.st_atime);
t->items[8] = MP_OBJ_NEW_SMALL_INT(sb.st_mtime);
diff --git a/unix/modsocket.c b/unix/modsocket.c
index 5b3fb01877..160a1dcc02 100644
--- a/unix/modsocket.c
+++ b/unix/modsocket.c
@@ -76,7 +76,7 @@ STATIC const mp_obj_type_t microsocket_type;
// Helper functions
#define RAISE_ERRNO(err_flag, error_val) \
{ if (err_flag == -1) \
- { nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((machine_int_t)error_val))); } }
+ { nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((mp_int_t)error_val))); } }
STATIC mp_obj_socket_t *socket_new(int fd) {
mp_obj_socket_t *o = m_new_obj(mp_obj_socket_t);
@@ -91,18 +91,18 @@ STATIC void socket_print(void (*print)(void *env, const char *fmt, ...), void *e
print(env, "<_socket %d>", self->fd);
}
-STATIC machine_int_t socket_read(mp_obj_t o_in, void *buf, machine_uint_t size, int *errcode) {
+STATIC mp_int_t socket_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) {
mp_obj_socket_t *o = o_in;
- machine_int_t r = read(o->fd, buf, size);
+ mp_int_t r = read(o->fd, buf, size);
if (r == -1) {
*errcode = errno;
}
return r;
}
-STATIC machine_int_t socket_write(mp_obj_t o_in, const void *buf, machine_uint_t size, int *errcode) {
+STATIC mp_int_t socket_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) {
mp_obj_socket_t *o = o_in;
- machine_int_t r = write(o->fd, buf, size);
+ mp_int_t r = write(o->fd, buf, size);
if (r == -1) {
*errcode = errno;
}
@@ -118,7 +118,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(socket_close_obj, socket_close);
STATIC mp_obj_t socket_fileno(mp_obj_t self_in) {
mp_obj_socket_t *self = self_in;
- return MP_OBJ_NEW_SMALL_INT((machine_int_t)self->fd);
+ return MP_OBJ_NEW_SMALL_INT((mp_int_t)self->fd);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(socket_fileno_obj, socket_fileno);
@@ -203,7 +203,7 @@ STATIC mp_obj_t socket_send(uint n_args, const mp_obj_t *args) {
int out_sz = send(self->fd, bufinfo.buf, bufinfo.len, flags);
RAISE_ERRNO(out_sz, errno);
- return MP_OBJ_NEW_SMALL_INT((machine_int_t)out_sz);
+ return MP_OBJ_NEW_SMALL_INT((mp_int_t)out_sz);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_send_obj, 2, 3, socket_send);
@@ -253,7 +253,7 @@ STATIC mp_obj_t socket_makefile(uint n_args, const mp_obj_t *args) {
mp_obj_socket_t *self = args[0];
mp_obj_t *new_args = alloca(n_args * sizeof(mp_obj_t));
memcpy(new_args + 1, args + 1, (n_args - 1) * sizeof(mp_obj_t));
- new_args[0] = MP_OBJ_NEW_SMALL_INT((machine_int_t)self->fd);
+ new_args[0] = MP_OBJ_NEW_SMALL_INT((mp_int_t)self->fd);
return mp_builtin_open(n_args, new_args);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_makefile_obj, 1, 3, socket_makefile);
@@ -319,7 +319,7 @@ STATIC const mp_obj_type_t microsocket_type = {
#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)));
+ return MP_OBJ_NEW_SMALL_INT((mp_int_t)htons(MP_OBJ_SMALL_INT_VALUE(arg)));
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_socket_htons_obj, mod_socket_htons);
@@ -341,7 +341,7 @@ STATIC mp_obj_t mod_socket_gethostbyname(mp_obj_t arg) {
struct hostent *h = gethostbyname(s);
if (h == NULL) {
// CPython: socket.herror
- nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((machine_int_t)h_errno)));
+ nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT((mp_int_t)h_errno)));
}
assert(h->h_length == 4);
return mp_obj_new_int(*(int*)*h->h_addr_list);
@@ -395,9 +395,9 @@ STATIC mp_obj_t mod_socket_getaddrinfo(uint n_args, const mp_obj_t *args) {
mp_obj_t list = mp_obj_new_list(0, NULL);
for (struct addrinfo *addr = addr_list; addr; addr = addr->ai_next) {
mp_obj_tuple_t *t = mp_obj_new_tuple(5, NULL);
- t->items[0] = MP_OBJ_NEW_SMALL_INT((machine_int_t)addr->ai_family);
- t->items[1] = MP_OBJ_NEW_SMALL_INT((machine_int_t)addr->ai_socktype);
- t->items[2] = MP_OBJ_NEW_SMALL_INT((machine_int_t)addr->ai_protocol);
+ t->items[0] = MP_OBJ_NEW_SMALL_INT((mp_int_t)addr->ai_family);
+ t->items[1] = MP_OBJ_NEW_SMALL_INT((mp_int_t)addr->ai_socktype);
+ t->items[2] = MP_OBJ_NEW_SMALL_INT((mp_int_t)addr->ai_protocol);
// "canonname will be a string representing the canonical name of the host
// if AI_CANONNAME is part of the flags argument; else canonname will be empty." ??
if (addr->ai_canonname) {
diff --git a/unix/modtime.c b/unix/modtime.c
index 286d8ea97e..15352735c6 100644
--- a/unix/modtime.c
+++ b/unix/modtime.c
@@ -68,7 +68,7 @@ STATIC mp_obj_t mod_time_time() {
mp_float_t val = tv.tv_sec + (mp_float_t)tv.tv_usec / 1000000;
return mp_obj_new_float(val);
#else
- return mp_obj_new_int((machine_int_t)time(NULL));
+ return mp_obj_new_int((mp_int_t)time(NULL));
#endif
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_time_time_obj, mod_time_time);
@@ -81,7 +81,7 @@ STATIC mp_obj_t mod_time_clock() {
// to preserve integer part resolution.
return mp_obj_new_float((float)(clock() / 1000) / CLOCK_DIV);
#else
- return mp_obj_new_int((machine_int_t)clock());
+ return mp_obj_new_int((mp_int_t)clock());
#endif
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_time_clock_obj, mod_time_clock);
diff --git a/unix/mpconfigport.h b/unix/mpconfigport.h
index 763b34ba3e..002ea79f94 100644
--- a/unix/mpconfigport.h
+++ b/unix/mpconfigport.h
@@ -83,16 +83,16 @@ extern const struct _mp_obj_module_t mp_module_ffi;
// type definitions for the specific machine
#ifdef __LP64__
-typedef long machine_int_t; // must be pointer size
-typedef unsigned long machine_uint_t; // must be pointer size
+typedef long mp_int_t; // must be pointer size
+typedef unsigned long mp_uint_t; // must be pointer size
#else
// These are definitions for machines where sizeof(int) == sizeof(void*),
// regardless for actual size.
-typedef int machine_int_t; // must be pointer size
-typedef unsigned int machine_uint_t; // must be pointer size
+typedef int mp_int_t; // must be pointer size
+typedef unsigned int mp_uint_t; // must be pointer size
#endif
-#define BYTES_PER_WORD sizeof(machine_int_t)
+#define BYTES_PER_WORD sizeof(mp_int_t)
typedef void *machine_ptr_t; // must be of pointer size
typedef const void *machine_const_ptr_t; // must be of pointer size