diff options
author | Omar Polo <op@omarpolo.com> | 2023-07-02 09:14:44 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2023-07-02 09:14:44 +0000 |
commit | 5d2f4b1611d724a3dbf0d4b8629119cf1ad11e87 (patch) | |
tree | b97025c500d44a54cd27168712535b883b946d5d /have | |
parent | c9c44c657187b6b312a863f01afa6ea5956cb84d (diff) |
add compat for endian (now required by imsg)
Diffstat (limited to 'have')
-rw-r--r-- | have/endian_h.c | 27 | ||||
-rw-r--r-- | have/machine_endian.c | 28 | ||||
-rw-r--r-- | have/sys_endian_h.c | 27 |
3 files changed, 82 insertions, 0 deletions
diff --git a/have/endian_h.c b/have/endian_h.c new file mode 100644 index 0000000..3bbff60 --- /dev/null +++ b/have/endian_h.c @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Omar Polo <op@omarpolo.com> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <endian.h> +#include <stdint.h> + +int +main(void) +{ + uint16_t x; + + x = 42; + return (htobe16(x)); +} diff --git a/have/machine_endian.c b/have/machine_endian.c new file mode 100644 index 0000000..2413b58 --- /dev/null +++ b/have/machine_endian.c @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Omar Polo <op@omarpolo.com> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <machine/endian.h> +#include <libkern/OSByteOrder.h> +#include <stdint.h> + +int +main(void) +{ + uint16_t x; + + x = 42; + return (OSSwapHostToBigInt16(x)); +} diff --git a/have/sys_endian_h.c b/have/sys_endian_h.c new file mode 100644 index 0000000..bba56c9 --- /dev/null +++ b/have/sys_endian_h.c @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2023 Omar Polo <op@omarpolo.com> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/endian.h> +#include <stdint.h> + +int +main(void) +{ + uint16_t x; + + x = 42; + return (htobe16(x)); +} |