From 2764a8ee8d507ee31c1ceab213fcfcbd1bbb37a6 Mon Sep 17 00:00:00 2001 From: Damien George Date: Sat, 18 Apr 2015 14:28:39 +0100 Subject: [PATCH] stmhal: Remove std.h. It's not needed anymore. --- drivers/cc3000/src/inet_ntop.c | 6 ++++- stmhal/modnwcc3k.c | 12 ++++------ stmhal/std.h | 42 ---------------------------------- 3 files changed, 9 insertions(+), 51 deletions(-) delete mode 100644 stmhal/std.h diff --git a/drivers/cc3000/src/inet_ntop.c b/drivers/cc3000/src/inet_ntop.c index c03ac44cd8..83242efa00 100644 --- a/drivers/cc3000/src/inet_ntop.c +++ b/drivers/cc3000/src/inet_ntop.c @@ -15,12 +15,16 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include #include #include "cc3000_common.h" #include "socket.h" #include "inet_ntop.h" +// We can't include stdio.h because it defines _types_fd_set, but we +// need to use the CC3000 version of this type. So we must provide +// our own declaration of snprintf. Grrr. +int snprintf(char *str, size_t size, const char *fmt, ...); + #define IN6ADDRSZ 16 #define INADDRSZ 4 #define INT16SZ 2 diff --git a/stmhal/modnwcc3k.c b/stmhal/modnwcc3k.c index fc412a7bb5..5236c3bdc1 100644 --- a/stmhal/modnwcc3k.c +++ b/stmhal/modnwcc3k.c @@ -24,10 +24,6 @@ * THE SOFTWARE. */ -// We can't include stdio.h because it defines _types_fd_set, but we -// need to use the CC3000 version of this type. - -#include #include #include #include @@ -531,9 +527,9 @@ STATIC mp_obj_t cc3k_ifconfig(mp_obj_t self_in) { mod_network_convert_ipv4_endianness(ipconfig.aucDHCPServer); // render MAC address - char mac_str[18]; + VSTR_FIXED(mac_vstr, 18); const uint8_t *mac = ipconfig.uaMacAddr; - mp_uint_t mac_len = snprintf(mac_str, 18, "%02X:%02x:%02x:%02x:%02x:%02x", mac[5], mac[4], mac[3], mac[2], mac[1], mac[0]); + vstr_printf(&mac_vstr, "%02x:%02x:%02x:%02x:%02x:%02x", mac[5], mac[4], mac[3], mac[2], mac[1], mac[0]); // create and return tuple with ifconfig info mp_obj_t tuple[7] = { @@ -542,7 +538,7 @@ STATIC mp_obj_t cc3k_ifconfig(mp_obj_t self_in) { mod_network_format_ipv4_addr(ipconfig.aucDefaultGateway), mod_network_format_ipv4_addr(ipconfig.aucDNSServer), mod_network_format_ipv4_addr(ipconfig.aucDHCPServer), - mp_obj_new_str(mac_str, mac_len, false), + mp_obj_new_str(mac_vstr.buf, mac_vstr.len, false), mp_obj_new_str((const char*)ipconfig.uaSSID, strlen((const char*)ipconfig.uaSSID), false), }; return mp_obj_new_tuple(MP_ARRAY_SIZE(tuple), tuple); @@ -566,7 +562,7 @@ STATIC mp_obj_t cc3k_patch_program(mp_obj_t self_in, mp_obj_t key_in) { if (key[0] == 'p' && key[1] == 'g' && key[2] == 'm' && key[3] == '\0') { patch_prog_start(); } else { - printf("pass 'pgm' as argument in order to program\n"); + mp_print_str(&mp_plat_print, "pass 'pgm' as argument in order to program\n"); } return mp_const_none; } diff --git a/stmhal/std.h b/stmhal/std.h deleted file mode 100644 index eb14a4f9a8..0000000000 --- a/stmhal/std.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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. - */ - -typedef unsigned int size_t; - -void *memcpy(void *dest, const void *src, size_t n); -void *memmove(void *dest, const void *src, size_t n); -void *memset(void *s, int c, size_t n); - -size_t strlen(const char *str); -int strcmp(const char *s1, const char *s2); -int strncmp(const char *s1, const char *s2, size_t n); -char *strcpy(char *dest, const char *src); -char *strcat(char *dest, const char *src); -char *strchr(const char *s, int c); -char *strstr(const char *haystack, const char *needle); - -int printf(const char *fmt, ...); -int snprintf(char *str, size_t size, const char *fmt, ...);