mirror of
https://github.com/thepigeongenerator/mcaselector-lite.git
synced 2025-12-19 00:25:44 +01:00
Compare commits
2 Commits
0baadfca75
...
e02e2a13f3
| Author | SHA1 | Date | |
|---|---|---|---|
| e02e2a13f3 | |||
| 8b952fb86f |
@@ -1,9 +1,45 @@
|
|||||||
/* Copyright (c) 2025 Quinn
|
/* Copyright (c) 2025 Quinn
|
||||||
* Licensed under the MIT Licence. See LICENSE for details */
|
* Licensed under the MIT Licence. See LICENSE for details */
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#if __has_include(<endian.h>)
|
#ifndef PORTABLE_ENDIAN_H
|
||||||
#include <endian.h>
|
#define PORTABLE_ENDIAN_H
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
|
||||||
|
/* test for the byteswap header */
|
||||||
|
#if __has_include(<byteswap.h>)
|
||||||
|
#include <byteswap.h>
|
||||||
|
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||||
|
#define le16toh(x) (x)
|
||||||
|
#define le32toh(x) (x)
|
||||||
|
#define le64toh(x) (x)
|
||||||
|
#define htole16(x) (x)
|
||||||
|
#define htole32(x) (x)
|
||||||
|
#define htole64(x) (x)
|
||||||
|
#define be16toh(x) __bswap16(x)
|
||||||
|
#define be32toh(x) __bswap32(x)
|
||||||
|
#define be64toh(x) __bswap64(x)
|
||||||
|
#define htobe16(x) __bswap16(x)
|
||||||
|
#define htobe32(x) __bswap32(x)
|
||||||
|
#define htobe64(x) __bswap64(x)
|
||||||
|
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||||
|
#define le16toh(x) __bswap16(x)
|
||||||
|
#define le32toh(x) __bswap32(x)
|
||||||
|
#define le64toh(x) __bswap64(x)
|
||||||
|
#define htole16(x) __bswap16(x)
|
||||||
|
#define htole32(x) __bswap32(x)
|
||||||
|
#define htole64(x) __bswap64(x)
|
||||||
|
#define be16toh(x) (x)
|
||||||
|
#define be32toh(x) (x)
|
||||||
|
#define be64toh(x) (x)
|
||||||
|
#define htobe16(x) (x)
|
||||||
|
#define htobe32(x) (x)
|
||||||
|
#define htobe64(x) (x)
|
||||||
|
#else
|
||||||
|
#error machine architecture unsupported! Expected either big-endian or little-endian, make sure to use a compiler which defines __BYTE_ORDER__ (like clang or gcc)
|
||||||
|
#endif /* byte order */
|
||||||
|
|
||||||
|
/* otherwise, utilise the compiler built-ins */
|
||||||
#else
|
#else
|
||||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||||
#define le16toh(x) __uint16_identity(x)
|
#define le16toh(x) __uint16_identity(x)
|
||||||
@@ -33,5 +69,12 @@
|
|||||||
#define htobe64(x) __uint64_identity(x)
|
#define htobe64(x) __uint64_identity(x)
|
||||||
#else
|
#else
|
||||||
#error machine architecture unsupported! Expected either big-endian or little-endian, make sure to use a compiler which defines __BYTE_ORDER__ (like clang or gcc)
|
#error machine architecture unsupported! Expected either big-endian or little-endian, make sure to use a compiler which defines __BYTE_ORDER__ (like clang or gcc)
|
||||||
#endif
|
#endif /* byte order */
|
||||||
#endif
|
|
||||||
|
#endif /* has byteswap.h */
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error GNU C is unavailable
|
||||||
|
#endif /* __GNUC__ */
|
||||||
|
|
||||||
|
#endif /* PORTABLE_ENDIAN_H */
|
||||||
12
makefile
12
makefile
@@ -9,15 +9,13 @@ VERSION = 0.0.0
|
|||||||
DEBUG ?= 0
|
DEBUG ?= 0
|
||||||
CC ?= cc
|
CC ?= cc
|
||||||
LD ?= ld
|
LD ?= ld
|
||||||
CFLAGS += -c -std=gnu99 -Wall -MMD -MP
|
|
||||||
CFLAGS += -Ilib/glad/include
|
|
||||||
LDFLAGS += -flto -lm
|
LDFLAGS += -flto -lm
|
||||||
MARCH ?= $(shell uname -m)
|
MARCH ?= $(shell uname -m)
|
||||||
KERNEL ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
|
KERNEL ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
# compilation flags
|
# compilation flags
|
||||||
CFLAGS = -c -std=gnu99 -Wall -Wextra -Wpedantic -MMD -MP
|
CFLAGS += -c -std=gnu99 -Wall -Wextra -Wpedantic -MMD -MP
|
||||||
LDFLAGS = -flto
|
LDFLAGS += -flto
|
||||||
|
|
||||||
# architecture/OS detection
|
# architecture/OS detection
|
||||||
ifeq ($(KERNEL),)
|
ifeq ($(KERNEL),)
|
||||||
@@ -53,7 +51,7 @@ PROF = rel
|
|||||||
CFLAGS += -DNDEBUG -O2
|
CFLAGS += -DNDEBUG -O2
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CFLAGS += $(shell pkg-config --cflags glfw3 libarchive) -Ilib/glad/include
|
CFLAGS += $(shell pkg-config --cflags glfw3 libarchive) -Ilib/include -Ilib/glad/include
|
||||||
LDFLAGS += $(shell pkg-config --libs glfw3 libarchive) -lm
|
LDFLAGS += $(shell pkg-config --libs glfw3 libarchive) -lm
|
||||||
|
|
||||||
# get source files
|
# get source files
|
||||||
@@ -81,8 +79,8 @@ compile: $(BIN)
|
|||||||
|
|
||||||
.PHONY .NOTPARALLEL:
|
.PHONY .NOTPARALLEL:
|
||||||
clean:
|
clean:
|
||||||
@rm -rv obj/
|
@[ -d obj/ ] && rm -rv obj/ || true
|
||||||
@rm -rv bin/
|
@[ -d bin/ ] && rm -rv bin/ || true
|
||||||
|
|
||||||
$(BIN): $(OBJ)
|
$(BIN): $(OBJ)
|
||||||
$(info [CC/LD] $@)
|
$(info [CC/LD] $@)
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
#include "mcx.h"
|
#include "mcx.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <endian.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "../util/compat/endian.h"
|
|
||||||
#include "../util/intdef.h"
|
#include "../util/intdef.h"
|
||||||
|
|
||||||
#define TABLE 0x2000 // table byte size
|
#define TABLE 0x2000 // table byte size
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
#include "nbt.h"
|
#include "nbt.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <endian.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "../util/compat/endian.h"
|
|
||||||
#include "../util/intdef.h"
|
#include "../util/intdef.h"
|
||||||
|
|
||||||
#define MAX_DEPTH 512
|
#define MAX_DEPTH 512
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <endian.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "../util/atrb.h"
|
#include "../util/atrb.h"
|
||||||
#include "../util/compat/endian.h"
|
|
||||||
#include "../util/intdef.h"
|
#include "../util/intdef.h"
|
||||||
|
|
||||||
/* NBT (named binary tag) is a tree data structure. Tags have a numeric type ID, name and a payload.
|
/* NBT (named binary tag) is a tree data structure. Tags have a numeric type ID, name and a payload.
|
||||||
|
|||||||
Reference in New Issue
Block a user