Skip to content

Commit dc2c8f0

Browse files
committed
esp8266/axtls_helpers: Helper/wrapper functions for axTLS.
1 parent 556e5df commit dc2c8f0

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

esp8266/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ SRC_C = \
7979
ets_alt_task.c \
8080
$(BUILD)/frozen.c \
8181
fatfs_port.c \
82+
axtls_helpers.c \
8283

8384
STM_SRC_C = $(addprefix stmhal/,\
8485
pybstdio.c \

esp8266/axtls_helpers.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2016 Paul Sokolovsky
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include <stdint.h>
28+
#include <stdio.h>
29+
#include "py/mphal.h"
30+
#include "py/gc.h"
31+
32+
// Functions for axTLS
33+
34+
void *malloc(size_t size) {
35+
return gc_alloc(size, false);
36+
}
37+
void free(void *ptr) {
38+
gc_free(ptr);
39+
}
40+
void *calloc(size_t nmemb, size_t size) {
41+
return m_malloc0(nmemb * size);
42+
}
43+
void *realloc(void *ptr, size_t size) {
44+
return gc_realloc(ptr, size, true);
45+
}
46+
void abort_(void) {
47+
printf("Aborted\n");
48+
}
49+
50+
#define PLATFORM_HTONL(_n) ((uint32_t)( (((_n) & 0xff) << 24) | (((_n) & 0xff00) << 8) | (((_n) >> 8) & 0xff00) | (((_n) >> 24) & 0xff) ))
51+
#undef htonl
52+
#undef ntohl
53+
uint32_t ntohl(uint32_t netlong) {
54+
return PLATFORM_HTONL(netlong);
55+
}
56+
uint32_t htonl(uint32_t netlong) {
57+
return PLATFORM_HTONL(netlong);
58+
}
59+
60+
time_t time(time_t *t) {
61+
return mp_hal_ticks_ms() / 1000;
62+
}
63+
64+
time_t mktime(void *tm) {
65+
return 0;
66+
}

0 commit comments

Comments
 (0)