Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
micropython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
micropython
Commits
503089ea
Commit
503089ea
authored
Oct 07, 2016
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unix: Use mp_raise_OSError helper function.
parent
23a56824
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
18 additions
and
16 deletions
+18
-16
unix/file.c
unix/file.c
+1
-1
unix/modffi.c
unix/modffi.c
+5
-4
unix/modmachine.c
unix/modmachine.c
+2
-2
unix/modos.c
unix/modos.c
+1
-1
unix/modsocket.c
unix/modsocket.c
+4
-4
unix/modtermios.c
unix/modtermios.c
+1
-1
unix/moduselect.c
unix/moduselect.c
+1
-1
unix/mphalport.h
unix/mphalport.h
+1
-1
unix/mpthreadport.c
unix/mpthreadport.c
+2
-1
No files found.
unix/file.c
View file @
503089ea
...
...
@@ -203,7 +203,7 @@ STATIC mp_obj_t fdfile_open(const mp_obj_type_t *type, mp_arg_val_t *args) {
const
char
*
fname
=
mp_obj_str_get_str
(
fid
);
int
fd
=
open
(
fname
,
mode_x
|
mode_rw
,
0644
);
if
(
fd
==
-
1
)
{
nlr_raise
(
mp_obj_new_exception_arg1
(
&
mp_type_OSError
,
MP_OBJ_NEW_SMALL_INT
(
errno
))
);
mp_raise_OSError
(
errno
);
}
o
->
fd
=
fd
;
return
MP_OBJ_FROM_PTR
(
o
);
...
...
unix/modffi.c
View file @
503089ea
...
...
@@ -35,6 +35,7 @@
#include "py/nlr.h"
#include "py/runtime.h"
#include "py/binary.h"
#include "py/mperrno.h"
/*
* modffi uses character codes to encode a value type, based on "struct"
...
...
@@ -215,7 +216,7 @@ STATIC mp_obj_t ffimod_func(size_t 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
(
ENOENT
))
);
mp_raise_OSError
(
MP_ENOENT
);
}
return
make_func
(
args
[
1
],
sym
,
args
[
3
]);
}
...
...
@@ -278,7 +279,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
(
ENOENT
))
);
mp_raise_OSError
(
MP_ENOENT
);
}
mp_obj_ffivar_t
*
o
=
m_new_obj
(
mp_obj_ffivar_t
);
o
->
base
.
type
=
&
ffivar_type
;
...
...
@@ -295,7 +296,7 @@ STATIC mp_obj_t ffimod_addr(mp_obj_t self_in, mp_obj_t symname_in) {
void
*
sym
=
dlsym
(
self
->
handle
,
symname
);
if
(
sym
==
NULL
)
{
nlr_raise
(
mp_obj_new_exception_arg1
(
&
mp_type_OSError
,
MP_OBJ_NEW_SMALL_INT
(
ENOENT
))
);
mp_raise_OSError
(
MP_ENOENT
);
}
return
mp_obj_new_int
((
uintptr_t
)
sym
);
}
...
...
@@ -312,7 +313,7 @@ STATIC mp_obj_t ffimod_make_new(const mp_obj_type_t *type, size_t n_args, size_t
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
(
errno
))
);
mp_raise_OSError
(
errno
);
}
mp_obj_ffimod_t
*
o
=
m_new_obj
(
mp_obj_ffimod_t
);
o
->
base
.
type
=
type
;
...
...
unix/modmachine.c
View file @
503089ea
...
...
@@ -27,7 +27,7 @@
#include <stdio.h>
#include <stdint.h>
#include "py/
nlr
.h"
#include "py/
runtime
.h"
#include "py/obj.h"
#include "extmod/machine_mem.h"
...
...
@@ -58,7 +58,7 @@ uintptr_t mod_machine_mem_get_addr(mp_obj_t addr_o, uint align) {
if
(
!
fd
)
{
fd
=
open
(
"/dev/mem"
,
O_RDWR
|
O_SYNC
);
if
(
fd
==
-
1
)
{
nlr_raise
(
mp_obj_new_exception_arg1
(
&
mp_type_OSError
,
MP_OBJ_NEW_SMALL_INT
(
errno
))
);
mp_raise_OSError
(
errno
);
}
}
...
...
unix/modos.c
View file @
503089ea
...
...
@@ -53,7 +53,7 @@ extern const mp_obj_type_t mp_fat_vfs_type;
#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(error_val))
); } }
{
mp_raise_OSError(error_val
); } }
STATIC
mp_obj_t
mod_os_stat
(
mp_obj_t
path_in
)
{
struct
stat
sb
;
...
...
unix/modsocket.c
View file @
503089ea
...
...
@@ -74,7 +74,7 @@ const mp_obj_type_t mp_type_socket;
// 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(error_val))
); } }
{
mp_raise_OSError(error_val
); } }
static
inline
mp_obj_t
mp_obj_from_sockaddr
(
const
struct
sockaddr
*
addr
,
socklen_t
len
)
{
return
mp_obj_new_bytes
((
const
byte
*
)
addr
,
len
);
...
...
@@ -400,7 +400,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
(
h_errno
))
);
mp_raise_OSError
(
h_errno
);
}
assert
(
h
->
h_length
==
4
);
return
mp_obj_new_int
(
*
(
int
*
)
*
h
->
h_addr_list
);
...
...
@@ -415,7 +415,7 @@ STATIC mp_obj_t mod_socket_inet_pton(mp_obj_t family_in, mp_obj_t addr_in) {
int
r
=
inet_pton
(
family
,
mp_obj_str_get_str
(
addr_in
),
binaddr
);
RAISE_ERRNO
(
r
,
errno
);
if
(
r
==
0
)
{
nlr_raise
(
mp_obj_new_exception_arg1
(
&
mp_type_OSError
,
MP_OBJ_NEW_SMALL_INT
(
EINVAL
))
);
mp_raise_OSError
(
MP_EINVAL
);
}
int
binaddr_len
=
0
;
switch
(
family
)
{
...
...
@@ -437,7 +437,7 @@ STATIC mp_obj_t mod_socket_inet_ntop(mp_obj_t family_in, mp_obj_t binaddr_in) {
vstr_t
vstr
;
vstr_init_len
(
&
vstr
,
family
==
AF_INET
?
INET_ADDRSTRLEN
:
INET6_ADDRSTRLEN
);
if
(
inet_ntop
(
family
,
bufinfo
.
buf
,
vstr
.
buf
,
vstr
.
len
)
==
NULL
)
{
nlr_raise
(
mp_obj_new_exception_arg1
(
&
mp_type_OSError
,
MP_OBJ_NEW_SMALL_INT
(
errno
))
);
mp_raise_OSError
(
errno
);
}
vstr
.
len
=
strlen
(
vstr
.
buf
);
return
mp_obj_new_str_from_vstr
(
&
mp_type_str
,
&
vstr
);
...
...
unix/modtermios.c
View file @
503089ea
...
...
@@ -35,7 +35,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(error_val))
); } }
{
mp_raise_OSError(error_val
); } }
STATIC
mp_obj_t
mod_termios_tcgetattr
(
mp_obj_t
fd_in
)
{
struct
termios
term
;
...
...
unix/moduselect.c
View file @
503089ea
...
...
@@ -33,7 +33,7 @@
#include <errno.h>
#include <poll.h>
#include "py/
nlr
.h"
#include "py/
runtime
.h"
#include "py/obj.h"
#include "py/objlist.h"
#include "py/objtuple.h"
...
...
unix/mphalport.h
View file @
503089ea
...
...
@@ -39,4 +39,4 @@ static inline void mp_hal_delay_us(mp_uint_t us) { usleep(us); }
#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(error_val))
); } }
{
mp_raise_OSError(error_val
); } }
unix/mpthreadport.c
View file @
503089ea
...
...
@@ -29,6 +29,7 @@
#include <errno.h>
#include "py/mpstate.h"
#include "py/runtime.h"
#include "py/mpthread.h"
#include "py/gc.h"
...
...
@@ -182,7 +183,7 @@ void mp_thread_create(void *(*entry)(void*), void *arg, size_t *stack_size) {
return
;
er:
nlr_raise
(
mp_obj_new_exception_arg1
(
&
mp_type_OSError
,
MP_OBJ_NEW_SMALL_INT
(
ret
))
);
mp_raise_OSError
(
ret
);
}
void
mp_thread_finish
(
void
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment