• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ucode/include/ucode/platform.h

  1 /*
  2  * Copyright (C) 2023 Jo-Philipp Wich <jo@mein.io>
  3  *
  4  * Permission to use, copy, modify, and/or distribute this software for any
  5  * purpose with or without fee is hereby granted, provided that the above
  6  * copyright notice and this permission notice appear in all copies.
  7  *
  8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 15  */
 16 
 17 #ifndef UCODE_PLATFORM_H
 18 #define UCODE_PLATFORM_H
 19 
 20 #include <signal.h>
 21 #include <fcntl.h>
 22 #include <time.h>
 23 
 24 #include "ucode/util.h"
 25 
 26 #ifdef NSIG
 27 # define UC_SYSTEM_SIGNAL_COUNT NSIG
 28 #else
 29 # define UC_SYSTEM_SIGNAL_COUNT (_SIGMAX + 1)
 30 #endif
 31 
 32 extern const char *uc_system_signal_names[];
 33 
 34 #if defined(__linux__)
 35 # include <endian.h>
 36 # include <sys/sysmacros.h>
 37 #elif defined(__APPLE__)
 38 # include <unistd.h>
 39 # include <crt_externs.h>
 40 # include <machine/endian.h>
 41 # include <libkern/OSByteOrder.h>
 42 
 43 # define htobe16(x) OSSwapHostToBigInt16(x)
 44 # define htole16(x) OSSwapHostToLittleInt16(x)
 45 # define be16toh(x) OSSwapBigToHostInt16(x)
 46 # define le16toh(x) OSSwapLittleToHostInt16(x)
 47 
 48 # define htobe32(x) OSSwapHostToBigInt32(x)
 49 # define htole32(x) OSSwapHostToLittleInt32(x)
 50 # define be32toh(x) OSSwapBigToHostInt32(x)
 51 # define le32toh(x) OSSwapLittleToHostInt32(x)
 52 
 53 # define htobe64(x) OSSwapHostToBigInt64(x)
 54 # define htole64(x) OSSwapHostToLittleInt64(x)
 55 # define be64toh(x) OSSwapBigToHostInt64(x)
 56 # define le64toh(x) OSSwapLittleToHostInt64(x)
 57 
 58 # define environ (*_NSGetEnviron())
 59 
 60 __hidden int pipe2(int[2], int);
 61 __hidden int sigtimedwait(const sigset_t *, siginfo_t *, const struct timespec *);
 62 
 63 static inline int
 64 execvpe(const char *program, char * const *argv, char * const *envp)
 65 {
 66         char **saved = environ;
 67         int rc;
 68 
 69         environ = (char **)envp;
 70         rc = execvp(program, argv);
 71         environ = saved;
 72 
 73         return rc;
 74 }
 75 #else
 76 # error Unsupported platform
 77 #endif
 78 
 79 #endif /* UCODE_PLATFORM_H */
 80 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt