| 1 | /* |
| 2 | * Copyright (c) 2007-2015, Cameron Rich |
| 3 | * |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions are met: |
| 8 | * |
| 9 | * * Redistributions of source code must retain the above copyright notice, |
| 10 | * this list of conditions and the following disclaimer. |
| 11 | * * Redistributions in binary form must reproduce the above copyright notice, |
| 12 | * this list of conditions and the following disclaimer in the documentation |
| 13 | * and/or other materials provided with the distribution. |
| 14 | * * Neither the name of the axTLS project nor the names of its contributors |
| 15 | * may be used to endorse or promote products derived from this software |
| 16 | * without specific prior written permission. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
| 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | */ |
| 30 | |
| 31 | /** |
| 32 | * @file os_port.h |
| 33 | * |
| 34 | * Some stuff to minimise the differences between windows and linux/unix |
| 35 | */ |
| 36 | |
| 37 | #ifndef HEADER_OS_PORT_H |
| 38 | #define |
| 39 | |
| 40 | #include "os_int.h" |
| 41 | #include <errno.h> |
| 42 | #include <sys/types.h> |
| 43 | #ifndef __ets__ |
| 44 | #include <arpa/inet.h> |
| 45 | #endif |
| 46 | #include <sys/time.h> |
| 47 | #include "config.h" |
| 48 | |
| 49 | ssize_t mp_stream_posix_write(void *sock_obj, const void *buf, size_t len); |
| 50 | ssize_t mp_stream_posix_read(void *sock_obj, void *buf, size_t len); |
| 51 | extern int mp_stream_errno; |
| 52 | |
| 53 | #if 1 |
| 54 | #define SOCKET_READ(A,B,C) mp_stream_posix_read((void*)A,B,C) |
| 55 | #define SOCKET_WRITE(A,B,C) mp_stream_posix_write((void*)A,B,C) |
| 56 | #define SOCKET_CLOSE(A) NOT_USED_IN_LIB_CODE |
| 57 | #define SOCKET_ERRNO() mp_stream_errno |
| 58 | #else |
| 59 | #define SOCKET_READ(A,B,C) read(A,B,C) |
| 60 | #define SOCKET_WRITE(A,B,C) write(A,B,C) |
| 61 | #define SOCKET_CLOSE(A) if (A >= 0) close(A) |
| 62 | #define SOCKET_ERRNO() errno |
| 63 | #endif |
| 64 | #define ax_calloc(x, y) calloc(x, y) |
| 65 | #define ax_open(x, y) open(x, y) |
| 66 | |
| 67 | #ifndef be64toh |
| 68 | #define be64toh(x) __be64_to_cpu(x) |
| 69 | #endif |
| 70 | |
| 71 | #define SSL_CTX_MUTEX_INIT(A) |
| 72 | #define SSL_CTX_MUTEX_DESTROY(A) |
| 73 | #define SSL_CTX_LOCK(A) |
| 74 | #define SSL_CTX_UNLOCK(A) |
| 75 | |
| 76 | #define TTY_FLUSH() |
| 77 | |
| 78 | #include "../../../extmod/crypto-algorithms/sha256.h" |
| 79 | |
| 80 | #define SHA256_CTX CRYAL_SHA256_CTX |
| 81 | #define SHA256_Init(a) sha256_init(a) |
| 82 | #define SHA256_Update(a, b, c) sha256_update(a, b, c) |
| 83 | #define SHA256_Final(a, b) sha256_final(b, a) |
| 84 | |
| 85 | #endif |
| 86 | |